M=10**9+7;n,*a=`dd`.split.map &:to_i;b=a.pop(n+1) s=0 c=b.reduce :+ a.each_with_index{|e,i|s+=e*c;c-=b[n-i]} p s