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