#include <bits/stdc++.h>
using namespace std;
vector<long long> a;
vector<long long> b;
int main() {
  long long n, ans = 0, x;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> x;
    a.push_back(x);
    b.push_back(x);
  }
  n--;
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  reverse(b.begin(), b.end());
  for (vector<long long>::iterator i = a.begin(), j = b.begin(); i < a.end();
       i++, j++)
    ans += *i * *j;
  cout << ans % 10007;
}
