#include <bits/stdc++.h>
using namespace std;
long long n, A[100005];
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> A[i];
  sort(A, A + n);
  int mid = n / 2;
  long long res = 0;
  for (int i = 0; i < mid; i++) {
    res = (res + A[i] * A[n - 1 - i] * 2) % 10007;
  }
  if (n & 1) res = (res + A[mid] * A[mid]) % 10007;
  cout << res << "\n";
}
