#include <bits/stdc++.h>
using namespace std;
long long mod = 10007;
int main(void) {
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < (long long)(n); i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  long long ans = 0;
  for (long long i = 0; i < (long long)(n); i++) {
    long long j = n - 1 - i;
    ans += a[i] * a[j];
    ans %= mod;
  }
  cout << ans << '\n';
  return 0;
}
