M=10**9+7;n,*a=`dd`.split.map &:to_i;b=a.pop(n+1);i=1 p a.zip(b).reduce(0){|s,(x,y)|(s+((i*=2)/2*x*y))%M}