#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, ans = 0;
  cin >> n;
  vector<long long> a(n), b;
  for (auto &u : a) cin >> u, b.push_back(u);
  sort(a.begin(), a.end());
  sort(b.rbegin(), b.rend());
  for (long long i = 0; i < n; ++i) ans += (a[i] * b[i]) % 10007;
  cout << ans % 10007 << endl;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(nullptr);
  solve();
}
