#include <bits/stdc++.h>
const double PI = acos(-0);
const int mod = 1000007;
const int maxn = 1e5 + 10;
const int inf = 0x3f3f3f3f;
const int NEXT[][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
using namespace std;
int a[100001];
int main() {
  int n, ans = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  sort(a + 1, a + 1 + n);
  for (int i = 1; i <= n; ++i)
    ans = (ans + (long long)a[i] * a[n - i + 1] % 10007) % 10007;
  printf("%d", ans);
  return 0;
}
