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