#include <bits/stdc++.h>
using namespace std;
void make_unique(vector<int>& a) {
  sort(a.begin(), a.end());
  a.erase(unique(a.begin(), a.end()), a.end());
}
void printDouble(double f, int p) {
  cout << fixed;
  cout << setprecision(p) << f << endl;
}
int Set(int N, int cur) { return N = N | (1 << cur); }
int Reset(int N, int cur) { return N = N & ~(1 << cur); }
bool Check(int N, int cur) { return (bool)(N & (1 << cur)); }
long long GCD(long long a, long long b) {
  if (b == 0) return a;
  return GCD(b, a % b);
}
long long LCM(long long a, long long b) { return a * b / GCD(a, b); }
long long POW(long long a, long long p) {
  long long res = 1, x = a;
  while (p) {
    if (p & 1) res = (res * x);
    x = (x * x);
    p >>= 1;
  }
  return res;
}
struct debugger {
  template <typename T>
  debugger& operator,(const T& v) {
    cerr << v << " ";
    return *this;
  }
} dbg;
const long long inf = 2147383647;
const long long MOD = 10007;
const double pi = 2 * acos(0.0);
const double eps = 1e-9;
int N;
long long A[1000005];
void solve() {
  long long res = 0;
  int i = 0, j = N - 1;
  while (i <= j) {
    long long mty = (A[i] * A[j]) % MOD;
    if (i != j) mty = (mty * 2LL) % MOD;
    res = (res + mty) % MOD;
    i++, j--;
  }
  cout << res << endl;
}
int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%I64d", &A[i]);
  }
  sort(A, A + N);
  solve();
  return 0;
}
