def list_sum(x):
    """Return the sum of all elements of a list."""
    if len(x) == 1:
        return x[0]
    elif len(x) == 2:
        return x[0] + x[1]
    else:
        return x[0] + list_sum(x[1:])