#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1000000000")
using namespace std;
const int maxn = (int)1e5 + 10;
int v[maxn];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d", &v[i]);
  }
  sort(v, v + n);
  long long ans = 0;
  int mod = 10007;
  for (int i = 0; i < n; i++) {
    ans += (long long)v[i] * (v[n - i - 1]);
  }
  cout << ans % mod << endl;
  return 0;
}
