#include <bits/stdc++.h>
using namespace std;
const long long mod = 10007;
int32_t main() {
  long long n;
  cin >> n;
  long long a[n];
  long long b[n];
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(a, a + n);
  sort(b, b + n);
  reverse(b, b + n);
  for (long long i = 0; i < n; i++) {
    ans += (b[i] * a[i]) % mod;
    ans %= mod;
  }
  cout << ans;
}
