#include <bits/stdc++.h>   using namespace std;   const long long maxn = 200010;   const long long MOD = 1e9 + 7;   const long long INF = 1e9;   const long long LINF = 1e18;   long long n, m, a[maxn], b[maxn];   map<long long, long long> M, N;   string s, ss;   set<long long> S;   long long l, r, h;   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cin >> n;     for (long long i = 0; i < n; i++) cin >> a[i];     sort(a, a + n);     long long ans = 0;     for (long long i = 0; i < n; i++)       ans += ((a[i] % 10007) * (a[n - i - 1] % 10007)) % 10007, ans %= 10007;     cout << ans;   }   