#include <bits/stdc++.h>
int findpivot(int a[], int i, int j);
void quicksort(int a[], int i, int j);
int main(void) {
  int N;
  scanf("%d", &N);
  int* arr = (int*)malloc(sizeof(int) * N);
  int i;
  for (i = 0; i < N; i++) scanf("%d", &arr[i]);
  quicksort(arr, 0, N - 1);
  long long sum = 0;
  for (i = 0; i < N; i++) {
    sum = sum + (long long)arr[i] * arr[N - 1 - i];
    if (sum >= 10007) sum = sum % 10007;
  }
  printf("%I64d\n", sum);
  return 0;
}
void quicksort(int a[], int i, int j) {
  if (i < j) {
    int key = findpivot(a, i, j);
    quicksort(a, i, key - 1);
    quicksort(a, key + 1, j);
  }
}
int findpivot(int a[], int i, int j) {
  int key = a[i];
  int p = i, q = j;
  while (q > p) {
    while (a[q] > key && q > p) {
      q--;
    }
    while (a[p] <= key && q > p) {
      p++;
    }
    int t = a[p];
    a[p] = a[q];
    a[q] = t;
  }
  a[i] = a[p];
  a[p] = key;
  return p;
}
