import Data.Int
import Data.Ratio

main = do
  n <- readLn
  as <- map read.words <$> getLine
  print $ solve (Mod n) (map Mod as)

solve :: ModInt -> [ModInt] -> ModInt
solve n as = sum $ zipWith (*) as $ map (*product[1..n]) ps where
  ps = map (subtract 1) $ zipWith (+) csr (reverse csr)
  csr = scanl1 (+) $ map recip [1..n]

modulo = 10^9+7

newtype ModInt = Mod Int deriving (Eq)

instance Show ModInt where
  show (Mod a) = show a
instance Bounded ModInt where
  maxBound = Mod $ modulo - 1
  minBound = Mod 0
-- Caution! If (value>=modulo), this does not work.
instance Enum ModInt where
  toEnum a = Mod $ mod a modulo
  fromEnum (Mod a) = a
instance Num ModInt where
  (Mod a) + (Mod b) = Mod $ mod (a+b) modulo
  (Mod a) * (Mod b) = Mod $ mod (a*b) modulo
  abs = id
  signum = const (Mod 1)
  fromInteger a = Mod $ fromIntegral $ mod a $ fromIntegral modulo
  negate (Mod 0) = Mod 0
  negate (Mod a) = Mod $ modulo - a
instance Fractional ModInt where
  recip a = a ^ (modulo-2)
  fromRational r = Mod (n * signum d) / Mod (abs d) where
    [n,d] = [fromIntegral] <*> ( [numerator,denominator] <*> [r] )
