local mod = 1000000007
local mfl, mce = math.floor, math.ceil
local function bmul(x, y)
  local x0, y0 = x % 31623, y % 31623
  local x1, y1 = mfl(x / 31623), mfl(y / 31623)
  return (x1 * y1 * 14122 + (x1 * y0 + x0 * y1) * 31623 + x0 * y0) % mod
end
local function badd(x, y) return mod <= x + y and x + y - mod or x + y end
local n = io.read("*n")
local invs = {1}
local invsum = {1}
for i = 2, n do
  invs[i] = bmul(mfl(mod / i), mod - invs[mod % i])
  invsum[i] = badd(invsum[i - 1], invs[i])
end
local fact = 1
for i = 2, n do
  fact = bmul(fact, i)
end
local ret = 0
for i = 1, n do
  local a = io.read("*n")
  local mul = 1
  if 1 < i then
    mul = badd(mul, invsum[i])
    mul = badd(mul, mod - 1)
  end
  if i < n then
    mul = badd(mul, invsum[n + 1 - i])
    mul = badd(mul, mod - 1)
  end
  mul = bmul(mul, fact)
  ret = badd(ret, bmul(a, mul))
end
print(ret)
