#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<iomanip>
#include<regex>
using namespace std;
#define int long long
const int mod=1e9+7;
signed main(){
	int n,a[100000],fib[100001];
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	fib[0]=fib[1]=1;
	for(int i=2;i<=n;i++)
		fib[i]=(fib[i-1]+fib[i-2])%mod;
	int ans=0;
	for(int i=0;i<n;i++)
		ans=(ans+(2*fib[i]*fib[n-i]-fib[n]+mod)%mod*a[i])%mod;
	cout<<ans<<endl;
}
#include <bits/stdc++.h> 
#include <stdio.h> 
#include <stdlib.h> 
#include <string.h> 
#include<vector>
#include<math.h> 
using namespace std; 
int gcd(int a, int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
  int main()
  {
      int t,n,i,j,k,l,a,b,c,flag,d;
      int arr[100001];
      char s[100001];
      vector<int> v;
     scanf("%d",&n);
     for(i=0;i<n;i++)
     scanf("%d",&arr[i]);
     int result = arr[0]; 
    for (int i = 1; i < n; i++) 
    { 
        result = gcd(arr[i], result); 
  
    } 
    printf("%d",result) ;
      
  }