#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, sum;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  sum = 0;
  for (int i = 0; i < N; i++) {
    sum = a.at(i) + sum;
  }
  cout << (sum * (N - 2)) % (1000000000 - 7) << endl;
}
