#include <bits/stdc++.h>
int main() {
  const int MOD = 10007;
  int N;
  std::cin >> N;
  long long int a[N], b[N];
  for (int i = 0; i < N; i++) {
    std::cin >> a[i];
    b[i] = a[i];
  }
  std::sort(b, b + N, std::greater<int>());
  std::sort(a, a + N);
  long long ans = 0;
  for (int i = 0; i < N; i++) {
    ans += a[i] * b[i];
    ans %= MOD;
  }
  std::cout << ans % MOD;
}
