#include <bits/stdc++.h>
using namespace std;
const double PI = 4 * atan(1.0);
const int MAXN = (int)(100010);
const int INF = (int)(1e9) + 20;
const int MOD = (int)(10007);
int dir[2][4] = {{-1, 0, 1, 0}, {0, 1, 0, -1}};
long long a[MAXN], b[MAXN];
int n;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(a, a + n);
  sort(b, b + n);
  long long ans = 0;
  for (int i = 0, j = n - 1; i < n; i++, j--) {
    ans = (ans + a[i] * b[j]) % MOD;
  }
  cout << ans << endl;
  return 0;
}
