#include <iostream>
using namespace std;
unsigned long getT(unsigned long val) {
unsigned long sum = 0;
for (unsigned long i = 1; i <= val; i++) {
sum += i;
}
return sum;
}
int main() {
unsigned long n;
cin >> n;
//unsigned long t[n];
unsigned long sum = 0;
for (unsigned long i = 0; i < n; i++) {
unsigned long tmp;
cin >> tmp;
//t[i] = tmp;
//sum += tmp;
sum += getT(tmp) * 2;
}
/*for (unsigned long length = 2; length <= n; length++) {
for (unsigned long i = 0; i < n - (length - 1); i++) {
for (unsigned long j = i; j < i + length; j++) {
sum += t[j];
}
}
}*/
cout << sum % 1000000007;
//while (1);
}