#include <bits/stdc++.h>
using namespace std;
const int mod = 10007;
long long a[100005], n, sum, i;
int main() {
  scanf("%lld", &n);
  sum = 0;
  for (i = 1; i <= n; i++) scanf("%lld", &a[i]);
  sort(a + 1, a + n + 1);
  for (i = 1; i <= n; i++) {
    sum = (sum + a[i] * a[n - i + 1] % mod) % mod;
  }
  printf("%lld\n", sum);
}
