#include <bits/stdc++.h>
using namespace std;
int a[100001];
int main(void) {
  int n, t = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  sort(a, a + n);
  for (int i = 0; i < n; i++) t += (long long)a[i] * a[n - i - 1] % 10007;
  t %= 10007;
  printf("%d", t);
  return 0;
}
