#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j, k;
  long long arr[100001];
  long long brr[100001];
  while (cin >> n) {
    for (i = 0; i < n; i++) {
      cin >> arr[i];
    }
    sort(arr, arr + n);
    j = 0;
    for (i = n - 1; i >= 0; i--) brr[j++] = arr[i];
    long long sum = 0;
    for (i = 0; i < n; i++) {
      sum += arr[i] * brr[i];
      sum %= 10007;
    }
    cout << sum % 10007 << endl;
  }
}
