#include <bits/stdc++.h>
using namespace std;
int n;
int a[100001];
int main() {
  scanf("%d", &n);
  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 += (long long)a[i] % 10007 * a[n - i - 1] % 10007 % 10007;
    sum %= 10007;
  }
  cout << sum;
}
