a=1 b=int(input()) c=list(map(int,input().split())) d=0 for i in range(b): d+=a*c[i] a=a*(b-1-i)//(i+1) print(d%(10**9+7))