#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 1;
const int INF = 1e9 + 9;
int a[MAXN];
int main() {
  int n;
  cin >> n;
  for (int i = 1, _b = (n); i <= _b; i++) cin >> a[i];
  sort(a + 1, a + n + 1);
  long long ans = 0;
  for (int i = 1, _b = (n); i <= _b; i++) {
    ans += (a[i] % 10007) * (a[n - i + 1] % 10007);
    ans %= 10007;
  }
  cout << ans;
}
