#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)(1e5) + 2;
const int inf = (int)(1e9) + 7;
const int mod = 1e4 + 7;
int n, a[maxn];
long long ans;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + 1 + n);
  for (int i = 1; i <= n; i++) {
    ans += a[i] * 1ll * a[n - i + 1];
    ans %= mod;
  }
  cout << ans;
  return 0;
}
