#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n, k;
  long long a[100000];
  long long sum = 0;
  long long score = 0;
  long long negt = 0;
  long long t = 0;
  cin >> n >> k;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  sort(a, a + n);
  for (long long i = 0; i < n; i++) {
    score += sum - a[i] * n;
    if (i == 0) continue;
    long long dif = a[i] - a[i - 1];
    negt -= dif * i;
    negt %= 1000000007;
    score -= negt;
    score %= 1000000007;
  }
  if (score < 0) score += 1000000007;
  cout << score << endl;
}
