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