#include <bits/stdc++.h>
using namespace std;
using LL = long long;
constexpr int N = 1e5 + 5;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> in(n);
  for (int &e : in) cin >> e;
  int res = 0;
  sort(begin(in), end(in));
  for (int &x : in) x %= 10007;
  for (int i = 0; i < n; i++) {
    res += in[i] * in[n - 1 - i] % 10007;
    res %= 10007;
  }
  cout << res << endl;
}
