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