n=int(input()) a=list(map(int,input().split())) c=[1] for i in range(1,n): c.append(c[i-1]*(n-1)/(i+1)) print(sum([(min(i,n-i-1)*2+1)*a[i] for i in range(n)])%(1000000007))