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