#include<bits/stdc++.h>
using namespace std;
unsigned long long n,a[100005],sum,dp[10][100005],N=1000000007;
int main(){
freopen("enumerate.in","r",stdin);
freopen("enumerate.out","w",stdout);
cin>>n;
for (int i=1;i<=n;i++){
scanf("%d",&a[i]);
dp[1][i]=dp[1][i-1]+a[i];
}
for (int i=2;i<=4;i++){
for (int j=i;j<=n;j++){
dp[i][j]=(dp[i-1][j-1]*a[j]+dp[i][j-1])%N;
}
}
cout<<dp[4][n];
return 0;
}