#include <bits/stdc++.h>
using namespace std;
int a[100000], b[100000];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    b[i] = a[i];
  }
  sort(a, a + n);
  sort(b, b + n, greater<int>());
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    ans = (ans + ((long long)a[i] * b[i] % 10007)) % 10007;
  }
  printf("%lld", ans);
}
