#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;
const double pi = acos(-1.0);
long long a[100010];
int main() {
  int n;
  cin >> n;
  long long ans = 0;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  for (int i = 0; i < n; i++) (ans += (a[i] * a[n - i - 1])) %= 10007;
  cout << ans << endl;
  return 0;
}
