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

def pow(a,b,mod)
  return 1 if b==0
  return (a**b[0]*pow(a,b/2,mod)**2)%mod
end

def inv(a,mod)
  pow(a,mod-2,mod)
end

mod=10**9+7

f=1
1.upto(n){|i|f=f*i%mod}

d=0,*(1..n).map{|j|f*inv(j,mod)%mod}

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=f+s[n-i]-s[1]+s[i+1]-s[1]
  r=(r+a[i]*q)%mod
}

p r