#include<bits/stdc++.h>
using namespace std;
const int M=1e5+5;
const int P=1e9+7;

int n,A[M];
long long dp[M][2];

void Dp()
{
	dp[0][0]=dp[1][0]=dp[1][1]=1;
	for(int i=2;i<=n;i++)
	{
		dp[i][0]=(dp[i-1][0]+dp[i-1][1])%P;
		dp[i][1]=dp[i-1][0];
//		printf("%d dp [0] %lld [1] %lld\n",i,dp[i][0],dp[i][1]);
	}
}

void Solve()
{
	Dp();
	long long Add=0,Sub=0;
	for(int i=1;i<=n;i++)(Add+=A[i]*dp[i-1][0]%P*dp[n-i+1][0])%=P;//,printf("%d Add %lld*%lld\n",i,dp[i-1][0],dp[n-i][0]%P);
	for(int i=2;i<=n;i++)(Sub+=A[i]*dp[i-1][1]%P*dp[n-i+1][1])%=P;
//	printf("%lld %lld\n",Add,Sub);
	printf("%lld\n",(Add+P-Sub)%P);
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&A[i]);
	Solve();
	return 0;
}
#include<bits/stdc++.h>
using namespace std;
#define lli   long long int
#define nl    "\n"
#define pb(k)  push_back(k)
#define vi     vector<int>

bool ispali(string s)
{
    bool ispalin = true;
    int i = 0 ; 
    int j = s.size() - 1 ; 
    while(i<j)
    {
        if(s[i]!=s[j])
        {
            ispalin = false;
        }
        i++;
        j--;
    } 
    return ispalin;
}
float distance(int x1, int y1, int x2, int y2)
{
    // Calculating distance
    return sqrt(pow(x2 - x1, 2) +
                pow(y2 - y1, 2) * 1.0);
}
void solve()
{

    int n;
    cin>>n;
    vi input1;
    vi input2;
    for(int i = 0 ; i<n ; ++i)
    {
        int k ; 
        cin>>k;
        input1.pb(k);
    }
    for(int i = 0 ; i<n ; ++i)
    {
        int k ; 
        cin>>k;
        input2.pb(k);
    }
    int sum = 0 ;
    for(int i = 0 ; i<n ; ++i)
    {
        sum += input1[i]*input2[i];
    }
    if(sum==0)
    {
        cout<<"Yes"<<nl;
    }
    else
    {
        cout<<"No"<<nl;
    }
   
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   #ifndef ONLINE_JUDGE
    freopen("input.txt" , "r" , stdin);
    freopen("output.txt" , "w" , stdout);
    #endif 
    solve();
    
}
//river 
//                                                                                                     




