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