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