#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ggdem=b;i<ggdem;++i)
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define mset(a,v) memset((a),(v),sizeof(a))
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;

const ll MOD=1000000007;

/*----------------FPOW----------------*/
ll fpow(ll b, ll e){
	ll res=1;
	while(e){
		if(e&1)res=res*b%MOD;
		b=b*b%MOD,e>>=1;
	}
	return res;
}

int main(){FIN;
	ll n; cin>>n;
	vector<ll> a(n);
	fore(i,0,n)cin>>a[i];
	vector<ll> fib(n+1);
	fib[0]=1;
	fib[1]=1;
	fore(i,2,n+1)fib[i]=(fib[i-1]+fib[i-2])%MOD;
	ll res=fib.back()*a[0]%MOD;
	if(n>=3){
		fore(i,1,n){
			ll t=fib.back();
			if(i==1||i==n-1)t=(t-2ll*fib[n-2])%MOD;
			else t=(t-2ll*fib[i-1]*fib[n-i-1])%MOD;
			//cout<<t<<"\n";
			if(t<0)t+=MOD;
			t=t*a[i]%MOD;
			res=(res+t)%MOD;
		}
	}
	cout<<res<<"\n";
	
	return 0;
}
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MOD = 1000000007;
const long long INF = 1LL << 60;

bool is_prime(long long N) {
  if (N == 1) return false;
  for (long long i = 2; i * i <= N; ++i) {
    if (N % i == 0) return false;
  }
  return true;
}

map<ll, ll> factorize(ll num) {
  map<ll, ll> primary_map;
  for (ll i = 2; i * i <= num; i++) {
    if (num % i != 0) continue;
    ll ex = 0;
    while (num % i == 0) {
      ex++;
      num /= i;
    }
    primary_map[i] += ex;
  }
  if (num != 1) primary_map[num] += 1;
  return primary_map;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  ll cnt = 1;
  map<ll, ll> result;
  for (ll i = 2; i <= n; i++) {
    map<ll, ll> m = factorize(i);
    for (ll i = 2; i <= n; i++) {
      if (is_prime(i)) result[i] = max(m[i], result[i]);
    }
  }
  auto begin = result.begin(), end = result.end();
  for (auto iter = begin; iter != end; iter++) {
    for (ll i = 0; i < iter->second; i++) {
      cnt *= iter->first;
    }
  }
  cout << cnt + 1 << endl;
}