n=gets.to_i
a=gets.split.map &:to_i

mod=10**9+7

f=[*1..n]
1.upto(n-1){|i|f[i]=f[i]*f[i-1]}
ff=f.last

d=0,*(1..n).map{|j|ff/j}

s=d.dup
1.upto(n){|i|s[i]+=s[i-1];s[i]%=mod}

r=0

n.times{|i|
  #q=[1,*2..(n-i),*2..(i+1)].map{|j|ff/j}.reduce(:+)
  q=ff+s[n-i]-s[1]+s[i+1]-s[1]
  r=(r+a[i]*q)%mod
}

p r