#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int const N=100010,P=1e9+7;
int n;
ll a[N],f[10][N];
int main(){
freopen("enumerate.in","r",stdin);
freopen("enumerate.out","w",stdout);
scanf("%d",&n);
for (int i=1;i<=n;i++){
scanf("%d",&a[i]);
f[1][i]=f[1][i-1]+a[i];
}
for (int i=2;i<=4;i++){
for (int j=i;j<=n;j++) f[i][j]=(f[i-1][j-1]*a[j]+f[i][j-1])%P;
}
printf("%lld",f[4][n]%P);
return 0;
}