#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const long long mod = 10007;
int n;
long long a[maxn], b[maxn];
int cmp(int x, int y) { return x > y; }
int main() {
  while (scanf("%d", &n) != EOF) {
    long long ans = 0LL;
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      b[i] = a[i];
    }
    sort(a + 1, a + n + 1);
    sort(b + 1, b + n + 1, cmp);
    for (int i = 1; i <= n; i++) {
      long long tmp = (a[i] * b[i]) % mod;
      ans = (ans + tmp) % mod;
    }
    printf("%I64d\n", ans);
  }
  return 0;
}
