#include <bits/stdc++.h>
using namespace std;
long long a[1000010], b[1010][1010], d[1000010], dp[1010][1010], p[1000010];
long long mn = 1e9, mx = -1e9, ans, cnt, sm = 1, n, m;
bool ok, okk, u[1000010], uu[510][510];
char ck[100010], ch[1010][1010];
int dx[5] = {0, 1, 0, -1}, dy[5] = {-1, 0, 1, 0};
vector<int> g[100010];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    d[i] = a[i];
  }
  sort(a, a + n);
  sort(d, d + n);
  for (int i = 0; i < n; i++) {
    ans += (a[i] * d[n - 1 - i]) % 10007;
    ans %= 10007;
  }
  cout << ans;
  return 0;
}
