#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<long long> v;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    long long b;
    cin >> b;
    v.push_back(b);
  }
  sort(v.begin(), v.end());
  long long res = 0;
  for (int i = 0; i < n; i++) {
    res += (v[i] * v[n - 1 - i]);
  }
  cout << (res % 10007) << endl;
  return 0;
}
