-- Try yukicoder -- author: Leonardone @ NEETSDKASU main = interact $ show . solve . map read . words solve (n:vs) = ans `mod` 10^9 + 7 where (xs, ys) = splitAt (n+1) vs zs = zip xs (reverse ys) ans = fst $ foldl f (0, 0) zs f (a, s) (x, y) = (a + y * (s + x), s + x)