import           Control.Exception (assert)
import           Data.List         (transpose)

main :: IO ()
main = do
  n <- readLn
  xs <- map read . words <$> getLine
  assert (length xs == n) $
    print $ solve n xs

solve :: Int -> [Int] -> Int
solve n xs =
  let
    ds = zipWith (-) (tail xs) xs
  in
    (sum $ zipWith (*) (coefficients (n - 1)) ds) `mod` (10 ^ (9 :: Int) + 7)

coefficients :: Integral a => a -- ^ N - 1 = 間隔の数
             -> [a]
coefficients 1 = [1]
coefficients n =
  let
    cs1 = coefficients (n - 1)
  in
    map ((+ factorial (n - 1)) . sum) $ transpose $ (0 : cs1) : dupEach cs1

factorial :: Integral a => a -> a
factorial n = product [1..n]

dupEach :: [a] -> [[a]]
dupEach []       = []
dupEach (x : xs) = ([x, x] ++ xs) : map (x :) (dupEach xs)
