#include <bits/stdc++.h>
using namespace std;
 
int main(){
 int N;
 cin >> N;
 int x[N];
 int i;
 for(i=0;i<N;++i){
   cin >> x[i];}
 for(i=0;i<N;++i){
    x[i] -= x[0];}
long long int count = 0;
 for(i=0;i<j;++i){
     for(int j=1;j<N;j++){
         count += (x[j]-x[i])*2;
         count %= 1000000007;
     }}
     cout << count << endl;
}