#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
double startTime;
double gct() { return ((double)clock() - startTime) / CLOCKS_PER_SEC; }
void suraj() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; i++) {
    int c;
    cin >> c;
    a[i] = c;
    b[i] = c;
  }
  sort(a.begin(), a.end());
  sort(b.rbegin(), b.rend());
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    ans += ll(a[i]) * ll(b[i]);
  }
  cout << ans % 10007 << "\n";
}
void suraj2() {}
void suraj3() {}
void suraj4() {}
int main() {
  startTime = (double)clock();
  suraj();
  return 0;
}
