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