type
  modRange = range[2..int.high]
  mint*[MOD: static[modRange]] = distinct int

#--- 型変換 ---#
proc toMint*(n: SomeInteger, MOD: static[modRange]): mint[MOD] {.inline.} =
  if n < -MOD: mint[MOD](n mod MOD + MOD)
  elif n < 0: mint[MOD](n + MOD)
  elif n >= MOD: mint[MOD](n mod MOD)
  else: mint[MOD](n)
proc toMint*(n: SomeInteger): mint[MOD] {.inline.} = n.toMint(1_000_000_007)

proc toInt*(n: mint): int {.inline.} = int(n)

#--- 逆元 ---#
proc inverse*(n: mint): mint {.inline.} =
  ## 逆元 O(log(MOD))
  ## 非再帰extGcd版: ax + by = 1 を満たす x が b を法とした a の逆元
  ## 参考: https://topcoder.g.hatena.ne.jp/iwiwi/20130105/1357363348
  var (a, x, b, y) = (n.MOD.int, 0, n.toInt, 1)
  while b != 0:
    let tmp = a div b
    a -= tmp * b; swap(a, b)
    x -= tmp * y; swap(x, y)
  assert(x.toMint(n.MOD).toInt * n.toInt mod MOD == 1)
  return x.toMint(n.MOD)

proc `~`*(n: mint): mint {.inline.} = n.inverse

#--- 単項演算子 ---#
proc `+`*(n: mint): mint {.inline.} = n
proc `-`*(n: mint): mint {.inline.} = (-n.toInt).toMint(n.MOD)
proc `$`*(n: mint): string {.inline.} = $n.toInt

#--- 二項演算子 ---#
# 比較 #
template extendComparisonOperatorToInt(op: untyped) =
  ## mint と int を混ぜて使ってもいいように比較演算子を拡張する
  proc op*(n: mint; m: int): bool {.inline.} = op(n, m.toMint(n.MOD))
  proc op*(n: int; m: mint): bool {.inline.} = op(n.toMint(m.MOD), m)

proc `<`*(n, m: mint): bool {.inline.} = n.toInt < m.toInt
extendComparisonOperatorToInt(`<`)
proc `<=`*(n, m: mint): bool {.inline.} = n.toInt <= m.toInt
extendComparisonOperatorToInt(`<=`)
proc `==`*(n, m: mint): bool {.inline.} = n.toInt == m.toInt
extendComparisonOperatorToInt(`==`)

# 算術 #
template extendArithmeticOperatorToInt(op: untyped) =
  ## mint と int を混ぜて使ってもいいように算術演算子を拡張する
  proc op*(n: mint; m: int): mint {.inline.} = op(n, m.toMint(n.MOD))
  proc op*(n: int; m: mint): mint {.inline.} = op(n.toMint(m.MOD), m)

proc `mod`*(n, m: mint): mint {.inline.} = (n.toInt mod m.toInt).toMint(n.MOD)
proc `mod`*(n: mint, m: int): mint {.inline.} = (n.toInt mod m).toMint(n.MOD)
proc `mod`*(n: int, m: mint): mint {.inline.} = (n mod m.toInt).toMint(n.MOD)
proc `%`*(n, m: mint): mint {.inline.} = n mod m
proc `%`*(n: mint, m: int): mint {.inline.} = n mod m
proc `%`*(n: int, m: mint): mint {.inline.} = n mod m
proc `+`*(n, m: mint): mint {.inline.} = (n.toInt + m.toInt).toMint(n.MOD)
extendArithmeticOperatorToInt(`+`)
proc `-`*(n, m: mint): mint {.inline.} = n + (-m)
extendArithmeticOperatorToInt(`-`)
proc `*`*(n, m: mint): mint {.inline.} = (n.toInt * m.toInt).toMint(n.MOD)
extendArithmeticOperatorToInt(`*`)
proc `div`*(n, m: mint): mint {.inline.} =
  ## O(log(MOD))
  n * m.inverse
extendArithmeticOperatorToInt(`div`)
proc `/`*(n, m: mint): mint {.inline.} = n div m
extendArithmeticOperatorToInt(`/`)

proc mul*(n: mint; m: int): mint =
  ## MOD が大きすぎるとき用の掛け算 O(log(m))  (足し算で掛け算を計算するので)
  result = m.toMint(n.MOD)
  var (n, m) = (n, m)
  while m != 0:
    if (m and 1) == 1: result = result + n
    n = n + n
    m = m shr 1
proc mul*(n, m: mint): mint = mul(n, m.toInt)
proc mul*(n: int; m: mint): mint = mul(m, n)

# 算術代入 #
proc `%=`*(n: var mint; m: mint | int) {.inline.} = (n = n % m.int)
proc `+=`*(n: var mint; m: mint | int) {.inline.} = (n = n + m.int)
proc `-=`*(n: var mint; m: mint | int) {.inline.} = (n = n - m.int)
proc `*=`*(n: var mint; m: mint | int) {.inline.} = (n = n * m.int)
proc `/=`*(n: var mint; m: mint | int) {.inline.} = (n = n / m.int)

#--- 累乗 ---#
proc pow*(n: mint; m: int): mint {.inline.} =
  # O(log(m))?
  var (nn, mm) = (n, abs(m).toMint(n.MOD).int)
  result = 1.toMint(nn.MOD)
  while mm != 0:
    if (mm and 1) == 1: result = result * nn
    nn = nn * nn
    mm = mm shr 1
  if m < 0: result = result.inverse
proc pow*(n, m: mint): mint {.inline.} = n.pow(m.toInt)
proc pow*(n: int; m: mint): mint {.inline.} = n.toMint(m.MOD).pow(m.toInt)

proc `^`*(n, m: mint): mint {.inline.} =
  ## O(log(m))?
  n.pow(m)
proc `^`*(n: mint; m: int): mint {.inline.} = n.pow(m)
proc `^`*(n: int; m: mint): mint {.inline.} = n.pow(m) # これは戻り値が mint でいいのか疑問ではある

#--- その他関数 ---#
proc inc*(x: var mint; y: int = 1) = (x += y)
proc inc*(x: var mint; y: mint) = (x += y)

proc dec*(x: var mint; y: int = 1) = (x -= y)
proc dec*(x: var mint; y: mint) = (x -= y)

#--- 場合の数（組み合わせとか）関係の関数 ---#
from math import nextPowerOfTwo

proc findZero(a: openArray[mint]): int =
  ## a[i] == 0 となるような i を二分探索で求める
  ## a.len^2 > int.high のとき，内部でオーバーフローする
  if a[0] == 0: return 0
  var (ok, ng) = (a.len, 0)
  while ok - ng > 1:
    let mid = (ok + ng) div 2
    if a[mid] == 0: ok = mid
    else: ng = mid
  return ok

proc facs*(T: typedesc[mint]; n: mint | int): T =
  ## n! mod T.MOD を求める（T.MOD が素数じゃないときは知らない）
  var factorials {.global.} = newSeq[int](min(T.MOD, 200_000.nextPowerOfTwo)).mapIt(it.toMint(T.MOD))
  factorials[0] = 1.toMint(T.MOD)
  let n = n.int
  if n >= T.MOD: return 0.toMint(T.MOD)
  if n >= factorials.len: factorials.setLen(n.nextPowerOfTwo + 1)
  if factorials[n] > 0: return factorials[n]
  let zi = findZero(factorials)
  for i in zi..n:
    factorials[i] = factorials[i - 1] * i
  return factorials[n]
proc facs*(m: mint, n: mint | int): mint = m.type.facs(n)

proc facInvs*(T: typedesc[mint]; n: mint | int): T =
  ## 1/n! mod T.MOD を求める（T.MOD が素数じゃないときは知らない）
  ## n が T.MOD 以上とかの不正な値のときは 0 を返す
  var factorialInverses {.global.} = newSeq[T](min(T.MOD, 200_000.nextPowerOfTwo))
  let n = n.int
  if n >= T.MOD: return 0.toMint(T.MOD)
  if n >= factorialInverses.len: factorialInverses.setLen(n.nextPowerOfTwo + 1)
  let len = factorialInverses.len
  if factorialInverses[n] > 0: return factorialInverses[n]
  factorialInverses[len - 1] = T.facs(len - 1).inverse
  for i in countdown(len - 2, 0):
    if factorialInverses[i] > 0: break
    factorialInverses[i] = factorialInverses[i + 1] * (i + 1)
  return factorialInverses[n]

template extendNumberOfCases(f: untyped) =
  ## mint と int を混ぜたり，int だけで
  ## 使ってもいいように場合の数を求める関数を拡張する
  proc f*(n: mint; r: int): mint = f(n, r.toMint(n.MOD))
  proc f*(n: int; r: mint): mint = f(n.toMint(r.MOD), r)

proc C*(n, r: mint): mint =
  let (n, r) = (n.toInt, r.toInt)
  if r < 0 or n < r: 0.toMint(result.MOD)
  else: result.type.facs(n) * result.type.facInvs(r) * result.type.facInvs(n - r)
extendNumberOfCases(C)

proc P*(n, r: mint): mint =
  let (n, r) = (n.toInt, r.toInt)
  if r < 0 or n < r: 0.toMint(n.MOD)
  else: facs[n] * facInvs[n - r]
extendNumberOfCases(P)

proc H*(n, r: mint): mint =
  if r == 0: 1.toMint(n.MOD)
  else: C(n + r - 1, r)
extendNumberOfCases(H)

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
import strutils, sequtils

const MOD = 1_000_000_007

let
  N = stdin.readLine.parseInt
  x = stdin.readLine.split.map(parseInt)

proc T(n, k: int): mint[MOD] =
  mint[MOD].facs(n) * k.toMint(MOD)^(-1)

var
  result = 0.toMint(MOD)
  s = 0.toMint(MOD)
for k in 1..N:
  let t = T(N - 1, k)
  result += -x[k - 1] * t
  s += t

result += x[^1] * s

echo result
