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