#include <bits/stdc++.h>
using namespace std;
long long N, a[100000], S = 0, P;
const int MOD = 10007;
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) cin >> a[i];
  sort(a, a + N);
  int l = 0, r = N - 1;
  while (l < N && r >= 0) {
    P = ((a[l] % MOD) * (a[r] % MOD)) % MOD;
    S += P;
    S %= MOD;
    l++;
    r--;
  }
  cout << S << endl;
  return 0;
}
