M=10**9+7 def extended_euclid_algorithm(a,b) d0,x0,y0,d1,x1,y1=a,1,0,b,0,1 until d1==0 q=d0/d1 d0,x0,y0,d1,x1,y1=d1,x1,y1,d0-q*d1,x0-q*x1,y0-q*y1 end [d0,x0,y0] end def inverse(a) d,x,y=extended_euclid_algorithm(a,M) x%M end n=gets.to_i-1 a=gets.split.map(&:to_i) ans=0 comb=1 a.each_with_index{|v,i| ans=(ans+comb*v)%M comb=(comb*(n-i)*inverse(i+1))%M } puts ans%M