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