#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U>
ostream& operator<<(ostream& o, const pair<T, U>& p) {
  o << "(" << p.first << "," << p.second << ")";
  return o;
}
template <class T>
ostream& operator<<(ostream& o, const vector<T>& v) {
  o << "[";
  for (T t : v) {
    o << t << ",";
  }
  o << "]";
  return o;
}
const int mod = 10007;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int(i) = 0; (i) < (int)(n); ++(i)) cin >> a[i];
  sort((a).begin(), (a).end());
  int ans = 0;
  for (int(i) = 0; (i) < (int)(n); ++(i)) a[i] %= mod;
  for (int(i) = 0; (i) < (int)(n); ++(i)) (ans += a[i] * a[n - i - 1]) %= mod;
  cout << ans << endl;
  return 0;
}
