v7 time O(A[0]*A[1]*A[2]*...*A[-1]) space O(n) Accepted