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