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]%mod}
ff=f.last

r=0

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

p r