#include <bits/stdc++.h>
using namespace std;
long long INF = (long long)1e20;
int iINF = (int)1e20;
int main() {
  long long n;
  cin >> n;
  vector<long long> b(n);
  vector<long long> a(n);
  for (int i = 0; i < n; cin >> a[i++])
    ;
  for (int i = 0; i < n; ++i) b[i] = a[i];
  sort(a.rbegin(), a.rend());
  sort(b.begin(), b.end());
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    ans = ans + b[i] * a[i];
    ans %= 10007;
  }
  cout << ans;
}
