import Control.Applicative import Control.Monad main :: IO () main = do n <- readLn solve <$> replicateM (n + 1) readLn <*> replicateM (n + 1) readLn >>= print solve :: [Int] -> [Int] -> Int solve as bs = f 0 (sum as `mod` pn) (reverse as) bs where pn = 10 ^ 9 + 7 f sm sa (a:as) (b:bs) = f ((sm + (b * sa `mod` pn)) `mod` pn) (sa - a) as bs f sm sa [] [] = sm