#include <bits/stdc++.h>
using namespace std;
int a[100000 + 5];
int main() {
  int n, b;
  while (scanf("%d", &n) != EOF) {
    for (int i = 0; i < n; i++) {
      scanf("%d", &a[i]);
    }
    sort(a, a + n);
    long long sum = 0;
    for (int i = 0; i < n; i++) {
      sum = (sum + a[i] % 10007 * a[n - i - 1] % 10007) % 10007;
    }
    b = sum;
    printf("%d\n", b);
  }
}
