#include <iostream>
#include <cmath>
using namespace std;
int main() {
unsigned long n;
cin >> n;
unsigned long t[n];
for (unsigned long i = 0; i < n; i++) {
cin >> t[i];
}
cout << (t[0] + t[n - 1]) * (t[(n - 1) / 2] + t[n - 1]);
//while (1);
return 0;
unsigned long sum = 0;
for (unsigned long length = 1; 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 % long(pow(10, 9) + 7);
while (1);
}