#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long int N = 1e5 + 5;
const long double PI = 3.14159265358;
vector<vector<long long int>> adj;
vector<bool> vis;
long long int c;
void dfs(long long int j) {
  vis[j] = true;
  c++;
  for (auto u : adj[j]) {
    if (!vis[u]) dfs(u);
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int t = 1;
  while (t--) {
    long long int n;
    cin >> n;
    long long int a[n];
    for (long long int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    long long int ans = 0;
    for (long long int i = 0; i < n; i++) {
      ans = (ans + (a[i] * a[n - 1 - i]) % 10007) % 10007;
    }
    cout << ans;
  }
  return 0;
}
