#include <bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
int n;
long long a[100010],dp[100010][5];
int main () {
freopen("enumerate.in","r",stdin);
freopen("enumerate.out","w",stdout);
cin >> n;
for (int i=1;i<=n;i++) cin >> a[i];
for (int i=0;i<=n;i++) dp[i][0]=1;
for (int i=1;i<=n;i++) {
for (int j=1;j<=4;j++) {
dp[i][j]=dp[i-1][j]+dp[i-1][j-1]*a[i];
dp[i][j]%=mod;
}
}
cout << dp[n][4] <<endl;
return 0;
}