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