@a=map$s+=<>,0..<>;($\+=$_*pop@a)%=1e9+7for<>;print