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