#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  long long n, a;
  vector<int> tasks;
  cin >> n;
  for (size_t i = 0; i < n; i++) {
    cin >> a;
    tasks.push_back(a);
  }
  sort(tasks.begin(), tasks.end());
  vector<int> levels{tasks};
  reverse(tasks.begin(), tasks.end());
  long long result = 0;
  for (size_t i = 0; i < n; i++) {
    result += (levels[i] % 10007 * tasks[i] % 10007) % 10007;
    result %= 10007;
  }
  cout << result << '\n';
  return 0;
}
