#include <bits/stdc++.h>
using namespace std;
const int mod = 1e4 + 7;
long long d[112345], l[112345];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> l[i];
    d[i] = l[i];
  }
  sort(l, l + n);
  sort(d, d + n);
  reverse(d, d + n);
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    ans += (l[i] * d[i]) % mod;
    ans %= mod;
  }
  cout << ans << endl;
}
