import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.InputMismatchException;

public class C {
	public static void main(String[] args) {
		FastScannerC sc = new FastScannerC(System.in);

		int N = sc.nextInt();
		ArrayList<Integer> arr = new ArrayList<>(N);
		for(int i = 0; i<N; i++) arr.add(sc.nextInt()%10007);
		Collections.sort(arr);
		int TOTAL = 0;
		for(int i = 0; i<N; i++){
			TOTAL += arr.get(i)*arr.get(N-1-i);
			TOTAL %=  10007;
		}
		System.out.println(TOTAL);
	}
}

class FastScannerC{
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private SpaceCharFilter filter;

    public FastScannerC(InputStream stream)
    {
        this.stream = stream;
    }

    public int read()
    {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars)
        {
            curChar = 0;
            try
            {
                numChars = stream.read(buf);
            } catch (IOException e)
            {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int nextInt()
    {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-')
        {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do
        {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public String next()
    {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do
        {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }

    public String nextLine()
    {
        int c = read();
        StringBuilder res = new StringBuilder();
        do
        {
            res.appendCodePoint(c);
            c = read();
        } while (!isLineEndChar(c));
        return res.toString();
    }

    public double nextDouble() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        double res = 0;
        while (!isSpaceChar(c) && c != '.') {
            if (c == 'e' || c == 'E')
                return res * Math.pow(10, nextInt());
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        }
        if (c == '.') {
            c = read();
            double m = 1;
            while (!isSpaceChar(c)) {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                m /= 10;
                res += (c - '0') * m;
                c = read();
            }
        }
        return res * sgn;
    }

    public long nextLong() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public boolean isSpaceChar(int c)
    {
        if (filter != null)
            return filter.isSpaceChar(c);
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public boolean isLineEndChar(int c)
    {
        if (filter != null)
            return filter.isSpaceChar(c);
        return c == '\n' || c == '\r' || c == -1;
    }

    public interface SpaceCharFilter
    {
        public boolean isSpaceChar(int ch);
    }
}


import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.InputMismatchException;

public class C {
	public static void main(String[] args) {
		FastScannerC sc = new FastScannerC(System.in);

		int N = sc.nextInt();
		ArrayList<Integer> arr = new ArrayList<>(N);
		for(int i = 0; i<N; i++) arr.add(sc.nextInt());
		Collections.sort(arr);
		int TOTAL = 0;
		for(int i = 0; i<N; i++){
			TOTAL += (arr.get(i)%10007)*(arr.get(N-1-i)%10007);
			TOTAL %=  10007;
		}
		System.out.println(TOTAL);
	}
}

class FastScannerC{
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private SpaceCharFilter filter;

    public FastScannerC(InputStream stream)
    {
        this.stream = stream;
    }

    public int read()
    {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars)
        {
            curChar = 0;
            try
            {
                numChars = stream.read(buf);
            } catch (IOException e)
            {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int nextInt()
    {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-')
        {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do
        {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public String next()
    {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do
        {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }

    public String nextLine()
    {
        int c = read();
        StringBuilder res = new StringBuilder();
        do
        {
            res.appendCodePoint(c);
            c = read();
        } while (!isLineEndChar(c));
        return res.toString();
    }

    public double nextDouble() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        double res = 0;
        while (!isSpaceChar(c) && c != '.') {
            if (c == 'e' || c == 'E')
                return res * Math.pow(10, nextInt());
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        }
        if (c == '.') {
            c = read();
            double m = 1;
            while (!isSpaceChar(c)) {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                m /= 10;
                res += (c - '0') * m;
                c = read();
            }
        }
        return res * sgn;
    }

    public long nextLong() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public boolean isSpaceChar(int c)
    {
        if (filter != null)
            return filter.isSpaceChar(c);
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public boolean isLineEndChar(int c)
    {
        if (filter != null)
            return filter.isSpaceChar(c);
        return c == '\n' || c == '\r' || c == -1;
    }

    public interface SpaceCharFilter
    {
        public boolean isSpaceChar(int ch);
    }
}


import java.lang.reflect.Array;
import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		final int mod = 10007;
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		int [] s= new int[n];
		for(int i=0;i<n;i++)
			s[i]=scan.nextInt();
		Arrays.sort(s);
		int ans=0;
		for(int i=0;i<n;i++)
			ans=(ans+s[i]%mod*s[n-i-1]%mod)%mod;
		System.out.println(ans);

	}

}


import java.lang.reflect.Array;
import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		final int mod = 10007;
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		int [] s= new int[n];
		for(int i=0;i<n;i++)
			s[i]=scan.nextInt();
		Arrays.sort(s);
		int ans=0;
		for(int i=0;i<n;i++)
			ans=ans+s[i]%mod*s[n-i-1]%mod;
		System.out.println(ans);

	}

}


import java.lang.reflect.Array;
import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		final int mod = 10007;
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		int [] s= new int[n];
		for(int i=0;i<n;i++)
			s[i]=scan.nextInt();
		Arrays.sort(s);
		int ans=0;
		for(int i=0;i<n;i++)
			ans=ans+(s[i]%mod*s[n-i-1]%mod)%mod;
		System.out.println(ans);

	}

}


import javafx.scene.Scene;

import java.util.Arrays;
import java.util.Scanner;

/**
 * Created by moh.mogh on 9/10/2016.
 */
public class Q1 {
   static Scanner scanner;
    static int n;
    static int  [] B;
    static int  [] a;

    public static void main(String[] args) {
        final long MOD=1007;
        scanner=new Scanner(System.in);
        n=scanner.nextInt();
        a=new int[n];
        B=new int[n];

        for (int i = 0; i <n ; i++) {
            a[i]=scanner.nextInt();
            B[i]=a[i];
        }
        //Arrays.sort(a);
        Arrays.sort(B);
        long sum=0;
        for (int i = 0; i <n ; i++) {
            sum+=a[i]*B[n-i-1];
        }
        System.out.println(sum%MOD);
    }
}


import javafx.scene.Scene;

import java.util.Arrays;
import java.util.Scanner;

/**
 * Created by moh.mogh on 9/10/2016.
 */
public class Q1 {
   static Scanner scanner;
    static int n;
    static int  [] B;
    static int  [] a;

    public static void main(String[] args) {
        final long MOD=10007;
        scanner=new Scanner(System.in);
        n=scanner.nextInt();
        a=new int[n];
        B=new int[n];
        for (int i = 0; i <n ; i++) {
            a[i]=scanner.nextInt();
            B[i]=a[i];
        }
        Arrays.sort(a);
        Arrays.sort(B);
        long sum=0;
        for (int i = 0; i <n ; i++) {
            sum+=a[i]*B[n-i-1];
        }
        System.out.println(sum%MOD);
    }
}


import javafx.scene.Scene;

import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

/**
 * Created by moh.mogh on 9/10/2016.
 */
public class Q1 {
   static Scanner scanner;
    static int n;
    static Long  [] B;
    static Long[] a;

    public static void main(String[] args) {
        final long MOD=10007;
        scanner=new Scanner(System.in);
        n=scanner.nextInt();
        a=new Long[(int) n];
        B=new Long[n];
        for (int i = 0; i <n ; i++) {
            a[i]=scanner.nextLong();
            B[i]=a[i];
        }
        Arrays.sort(a);
        Arrays.sort(B);
        long sum=0;
        for (int i = 0; i <n ; i++) {
            sum+=a[i]*B[n-i-1];
        }
        System.out.println(sum%MOD);
    }
}


import javafx.scene.Scene;

import java.util.Arrays;
import java.util.Scanner;

/**
 * Created by moh.mogh on 9/10/2016.
 */
public class Q1 {
   static Scanner scanner;
    static int n;
    static int  [] B;
    static int  [] a;

    public static void main(String[] args) {
        final long MOD=1007;
        scanner=new Scanner(System.in);
        n=scanner.nextInt();
        a=new int[n];
        B=new int[n];

        for (int i = 0; i <n ; i++) {
            a[i]=scanner.nextInt();
            B[i]=a[i];
        }
        Arrays.sort(a);
        Arrays.sort(B);
        long sum=0;
        for (int i = 0; i <n ; i++) {
            sum+=a[i]*B[n-i-1];
        }
        System.out.println(sum%MOD);
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main717C {

    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    public static class Task {
        public void solve(InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int a[] = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            Arrays.sort(a);

            long result = 0L;
            for (int i = 0; i < n; i++) {
                result += (long) a[i] * a[n - i - 1];
            }
            out.print(result);
        }
    }

    public static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main717C {

    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    public static class Task {
        public void solve(InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int a[] = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            Arrays.sort(a);

            long result = 0L;
            for (int i = 0; i < n; i++) {
                result += (long) a[i] * a[n - i - 1];
            }
            out.print(result % 10007L);
        }
    }

    public static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }

}


import java.io.*;
import java.util.Locale;
import java.util.StringTokenizer;

/**
 * Created by DNs on 15.05.2016.
 */
public class Main implements Runnable {
  static BufferedReader in;
  static PrintWriter out;
  static StringTokenizer tok = new StringTokenizer("");

  public static void main(String[] args) {
    new Thread(new Main()).start();
  }

  @Override
  public void run() {
    Locale.setDefault(Locale.ENGLISH);
    try {
      init();
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    }
    try {
      solve();
    } catch (IOException e) {
      e.printStackTrace();
    }
    out.close();
  }

  private String readString() {
    while (!tok.hasMoreTokens()) {
      try {
        tok = new StringTokenizer(in.readLine());
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
    return tok.nextToken();
  }

  private Integer readInt() {
    return Integer.parseInt(readString());
  }

  private Long readLong() {
    return Long.parseLong(readString());
  }

  private Double readDouble() {
    return Double.parseDouble(readString());
  }

  private void init() throws FileNotFoundException {
    in = new BufferedReader(new InputStreamReader(System.in));
    out = new PrintWriter(System.out);
    /*in = new BufferedReader(new FileReader("stupid_rmq.in"));
    out = new PrintWriter("stupid_rmq.out");*/
  }

  private void solve() throws IOException {
    int n = readInt();
    long[] a = new long[n];
    for (int i = 0; i < n; i++) {
      a[i] = readInt();
    }
    long sum = 0;
    long mod =10007;

    for (int i = 0; i < n; i++) {
      sum+= a[i]*a[n-i-1];
      sum =  sum%mod;
    }
    out.print(sum);
  }

  class pair {
    int l, r;
    char color;

    public pair(int l, int r, char color) {
      this.l = l;
      this.r = r;
      this.color = color;
    }
  }

//road to blue
}


import java.io.*;
import java.util.Arrays;
import java.util.Locale;
import java.util.StringTokenizer;

/**
 * Created by DNs on 15.05.2016.
 */
public class Main implements Runnable {
  static BufferedReader in;
  static PrintWriter out;
  static StringTokenizer tok = new StringTokenizer("");

  public static void main(String[] args) {
    new Thread(new Main()).start();
  }

  @Override
  public void run() {
    Locale.setDefault(Locale.ENGLISH);
    try {
      init();
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    }
    try {
      solve();
    } catch (IOException e) {
      e.printStackTrace();
    }
    out.close();
  }

  private String readString() {
    while (!tok.hasMoreTokens()) {
      try {
        tok = new StringTokenizer(in.readLine());
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
    return tok.nextToken();
  }

  private Integer readInt() {
    return Integer.parseInt(readString());
  }

  private Long readLong() {
    return Long.parseLong(readString());
  }

  private Double readDouble() {
    return Double.parseDouble(readString());
  }

  private void init() throws FileNotFoundException {
    in = new BufferedReader(new InputStreamReader(System.in));
    out = new PrintWriter(System.out);
    /*in = new BufferedReader(new FileReader("stupid_rmq.in"));
    out = new PrintWriter("stupid_rmq.out");*/
  }

  private void solve() throws IOException {
    int n = readInt();
    long[] a = new long[n];
    for (int i = 0; i < n; i++) {
      a[i] = readInt();
    }
    Arrays.sort(a);
    long sum = 0;
    long mod = 10007;

    for (int i = 0; i < n; i++) {
      sum += a[i] * a[n - i - 1];
      sum = sum % mod;
    }
    out.print(sum);
  }

  class pair {
    int l, r;
    char color;

    public pair(int l, int r, char color) {
      this.l = l;
      this.r = r;
      this.color = color;
    }
  }

//road to blue
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.Random;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author MaxHeap
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    PotionsHomework solver = new PotionsHomework();
    solver.solve(1, in, out);
    out.close();
  }

  static class PotionsHomework {

    final int MOD = 10007;

    public void solve(int testNumber, InputReader in, PrintWriter out) {
      int n = in.nextInt();
      int[] laz = in.nextIntArray(n);
      ArrayUtils.sort(laz);
      long ans = 0;
      for (int i = 0; i < n; ++i) {
        ans += ((laz[i] * (long) laz[n - i - 1]));
      }
      out.println(ans % MOD);
    }

  }

  static class ArrayUtils {

    public static void sort(int[] arr) {
      int n = arr.length;
      Random r = new Random();
      for (int i = 0; i < n; i++) {
        int p = r.nextInt(n + 1);
        if (p < n) {
          int temp = arr[i];
          arr[i] = arr[p];
          arr[p] = temp;
        }
      }
      Arrays.sort(arr);
    }

  }

  static class InputReader implements FastIO {

    private InputStream stream;
    private byte[] buf = new byte[1 << 13];
    private int curChar;
    private int numChars;

    public InputReader(InputStream stream) {
      this.stream = stream;
    }

    public int read() {
      if (this.numChars == -1) {
        throw new UnknownError();
      } else {
        if (this.curChar >= this.numChars) {
          this.curChar = 0;

          try {
            this.numChars = this.stream.read(this.buf);
          } catch (IOException ex) {
            throw new InputMismatchException();
          }

          if (this.numChars <= 0) {
            return -1;
          }
        }

        return this.buf[this.curChar++];
      }
    }

    public int nextInt() {
      int c;
      for (c = this.read(); isSpaceChar(c); c = this.read()) {
      }

      byte sgn = 1;
      if (c == 45) {
        sgn = -1;
        c = this.read();
      }

      int res = 0;

      while (c >= 48 && c <= 57) {
        res *= 10;
        res += c - 48;
        c = this.read();
        if (isSpaceChar(c)) {
          return res * sgn;
        }
      }

      throw new InputMismatchException();
    }

    public static boolean isSpaceChar(int c) {
      return c == 32 || c == 10 || c == 13 || c == 9 || c == -1;
    }

    public int[] nextIntArray(int n) {
      int[] arr = new int[n];
      for (int i = 0; i < n; i++) {
        arr[i] = nextInt();
      }
      return arr;
    }

  }

  static interface FastIO {

  }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.Random;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author MaxHeap
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    PotionsHomework solver = new PotionsHomework();
    solver.solve(1, in, out);
    out.close();
  }

  static class PotionsHomework {

    final int MOD = 100007;

    public void solve(int testNumber, InputReader in, PrintWriter out) {
      int n = in.nextInt();
      int[] laz = new int[n];
      int[] dif = new int[n];
      for (int i = 0; i < n; ++i) {
        laz[i] = dif[i] = in.nextInt();
      }
      ArrayUtils.sort(laz);
      ArrayUtils.sort(dif);
      int f = compute(laz, dif);
      int s = compute(dif, laz);
      out.println(Math.min(f, s));
    }

    private int compute(int[] a, int[] b) {
      int ret = 0;
      for (int i = 0, j = a.length - 1; i < a.length; ++i, --j) {
        ret += (int) (((long) a[i] * (long) b[j]) % MOD);
        ret %= MOD;
      }
      return ret;
    }

  }

  static class ArrayUtils {

    public static void sort(int[] arr) {
      int n = arr.length;
      Random r = new Random();
      for (int i = 0; i < n; i++) {
        int p = r.nextInt(n + 1);
        if (p < n) {
          int temp = arr[i];
          arr[i] = arr[p];
          arr[p] = temp;
        }
      }
      Arrays.sort(arr);
    }

  }

  static class InputReader implements FastIO {

    private InputStream stream;
    private byte[] buf = new byte[1 << 13];
    private int curChar;
    private int numChars;

    public InputReader(InputStream stream) {
      this.stream = stream;
    }

    public int read() {
      if (this.numChars == -1) {
        throw new UnknownError();
      } else {
        if (this.curChar >= this.numChars) {
          this.curChar = 0;

          try {
            this.numChars = this.stream.read(this.buf);
          } catch (IOException ex) {
            throw new InputMismatchException();
          }

          if (this.numChars <= 0) {
            return -1;
          }
        }

        return this.buf[this.curChar++];
      }
    }

    public int nextInt() {
      int c;
      for (c = this.read(); isSpaceChar(c); c = this.read()) {
      }

      byte sgn = 1;
      if (c == 45) {
        sgn = -1;
        c = this.read();
      }

      int res = 0;

      while (c >= 48 && c <= 57) {
        res *= 10;
        res += c - 48;
        c = this.read();
        if (isSpaceChar(c)) {
          return res * sgn;
        }
      }

      throw new InputMismatchException();
    }

    public static boolean isSpaceChar(int c) {
      return c == 32 || c == 10 || c == 13 || c == 9 || c == -1;
    }

  }

  static interface FastIO {

  }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.Random;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author MaxHeap
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    PotionsHomework solver = new PotionsHomework();
    solver.solve(1, in, out);
    out.close();
  }

  static class PotionsHomework {

    final int MOD = 10007;

    public void solve(int testNumber, InputReader in, PrintWriter out) {
      int n = in.nextInt();
      int[] laz = new int[n];
      int[] dif = new int[n];
      for (int i = 0; i < n; ++i) {
        laz[i] = dif[i] = in.nextInt();
      }
      ArrayUtils.sort(laz);
      ArrayUtils.sort(dif);
      int f = compute(laz, dif);
      int s = compute(dif, laz);
      out.println(Math.min(f, s));
    }

    private int compute(int[] a, int[] b) {
      int ret = 0;
      for (int i = 0, j = a.length - 1; i < a.length; ++i, --j) {
        ret += (int) (((long) a[i] * (long) b[j]) % MOD);
        ret %= MOD;
      }
      return ret;
    }

  }

  static class ArrayUtils {

    public static void sort(int[] arr) {
      int n = arr.length;
      Random r = new Random();
      for (int i = 0; i < n; i++) {
        int p = r.nextInt(n + 1);
        if (p < n) {
          int temp = arr[i];
          arr[i] = arr[p];
          arr[p] = temp;
        }
      }
      Arrays.sort(arr);
    }

  }

  static class InputReader implements FastIO {

    private InputStream stream;
    private byte[] buf = new byte[1 << 13];
    private int curChar;
    private int numChars;

    public InputReader(InputStream stream) {
      this.stream = stream;
    }

    public int read() {
      if (this.numChars == -1) {
        throw new UnknownError();
      } else {
        if (this.curChar >= this.numChars) {
          this.curChar = 0;

          try {
            this.numChars = this.stream.read(this.buf);
          } catch (IOException ex) {
            throw new InputMismatchException();
          }

          if (this.numChars <= 0) {
            return -1;
          }
        }

        return this.buf[this.curChar++];
      }
    }

    public int nextInt() {
      int c;
      for (c = this.read(); isSpaceChar(c); c = this.read()) {
      }

      byte sgn = 1;
      if (c == 45) {
        sgn = -1;
        c = this.read();
      }

      int res = 0;

      while (c >= 48 && c <= 57) {
        res *= 10;
        res += c - 48;
        c = this.read();
        if (isSpaceChar(c)) {
          return res * sgn;
        }
      }

      throw new InputMismatchException();
    }

    public static boolean isSpaceChar(int c) {
      return c == 32 || c == 10 || c == 13 || c == 9 || c == -1;
    }

  }

  static interface FastIO {

  }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.Random;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author MaxHeap
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    PotionsHomework solver = new PotionsHomework();
    solver.solve(1, in, out);
    out.close();
  }

  static class PotionsHomework {

    final int MOD = 100007;

    public void solve(int testNumber, InputReader in, PrintWriter out) {
      int n = in.nextInt();
      int[] laz = in.nextIntArray(n);
      ArrayUtils.sort(laz);
      int ans = 0;
      for (int i = 0; i < n; ++i) {
        ans += (int) ((laz[i] * (long) laz[n - i - 1]) % MOD);
        ans %= MOD;
      }
      out.println(ans);
    }

  }

  static class ArrayUtils {

    public static void sort(int[] arr) {
      int n = arr.length;
      Random r = new Random();
      for (int i = 0; i < n; i++) {
        int p = r.nextInt(n + 1);
        if (p < n) {
          int temp = arr[i];
          arr[i] = arr[p];
          arr[p] = temp;
        }
      }
      Arrays.sort(arr);
    }

  }

  static class InputReader implements FastIO {

    private InputStream stream;
    private byte[] buf = new byte[1 << 13];
    private int curChar;
    private int numChars;

    public InputReader(InputStream stream) {
      this.stream = stream;
    }

    public int read() {
      if (this.numChars == -1) {
        throw new UnknownError();
      } else {
        if (this.curChar >= this.numChars) {
          this.curChar = 0;

          try {
            this.numChars = this.stream.read(this.buf);
          } catch (IOException ex) {
            throw new InputMismatchException();
          }

          if (this.numChars <= 0) {
            return -1;
          }
        }

        return this.buf[this.curChar++];
      }
    }

    public int nextInt() {
      int c;
      for (c = this.read(); isSpaceChar(c); c = this.read()) {
      }

      byte sgn = 1;
      if (c == 45) {
        sgn = -1;
        c = this.read();
      }

      int res = 0;

      while (c >= 48 && c <= 57) {
        res *= 10;
        res += c - 48;
        c = this.read();
        if (isSpaceChar(c)) {
          return res * sgn;
        }
      }

      throw new InputMismatchException();
    }

    public static boolean isSpaceChar(int c) {
      return c == 32 || c == 10 || c == 13 || c == 9 || c == -1;
    }

    public int[] nextIntArray(int n) {
      int[] arr = new int[n];
      for (int i = 0; i < n; i++) {
        arr[i] = nextInt();
      }
      return arr;
    }

  }

  static interface FastIO {

  }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.Random;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author MaxHeap
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    PotionsHomework solver = new PotionsHomework();
    solver.solve(1, in, out);
    out.close();
  }

  static class PotionsHomework {

    final int MOD = 100007;

    public void solve(int testNumber, InputReader in, PrintWriter out) {
      int n = in.nextInt();
      int[] laz = in.nextIntArray(n);
      ArrayUtils.sort(laz);
      long ans = 0;
      for (int i = 0; i < n; ++i) {
        ans += ((laz[i] * (long) laz[n - i - 1]));
      }
      out.println(ans % MOD);
    }

  }

  static class ArrayUtils {

    public static void sort(int[] arr) {
      int n = arr.length;
      Random r = new Random();
      for (int i = 0; i < n; i++) {
        int p = r.nextInt(n + 1);
        if (p < n) {
          int temp = arr[i];
          arr[i] = arr[p];
          arr[p] = temp;
        }
      }
      Arrays.sort(arr);
    }

  }

  static class InputReader implements FastIO {

    private InputStream stream;
    private byte[] buf = new byte[1 << 13];
    private int curChar;
    private int numChars;

    public InputReader(InputStream stream) {
      this.stream = stream;
    }

    public int read() {
      if (this.numChars == -1) {
        throw new UnknownError();
      } else {
        if (this.curChar >= this.numChars) {
          this.curChar = 0;

          try {
            this.numChars = this.stream.read(this.buf);
          } catch (IOException ex) {
            throw new InputMismatchException();
          }

          if (this.numChars <= 0) {
            return -1;
          }
        }

        return this.buf[this.curChar++];
      }
    }

    public int nextInt() {
      int c;
      for (c = this.read(); isSpaceChar(c); c = this.read()) {
      }

      byte sgn = 1;
      if (c == 45) {
        sgn = -1;
        c = this.read();
      }

      int res = 0;

      while (c >= 48 && c <= 57) {
        res *= 10;
        res += c - 48;
        c = this.read();
        if (isSpaceChar(c)) {
          return res * sgn;
        }
      }

      throw new InputMismatchException();
    }

    public static boolean isSpaceChar(int c) {
      return c == 32 || c == 10 || c == 13 || c == 9 || c == -1;
    }

    public int[] nextIntArray(int n) {
      int[] arr = new int[n];
      for (int i = 0; i < n; i++) {
        arr[i] = nextInt();
      }
      return arr;
    }

  }

  static interface FastIO {

  }
}


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication1;

import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import static java.util.Collections.list;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

/**
 *
 * @author george
 */
public class main {
 static boolean  isPrime(int n) {
    for(int i=2;i<n;i++) {
        if(n%i==0)
            return false;
    }
    return true;
}
static public class Princess{
 public int rate;public int beauty;public int intellect;public int richness;
 public Princess(int sum,int a,int b,int c){
  this.rate=sum;
  this.beauty=a;
  this.intellect=b;
  this.richness=c;
  }

        @Override
        public String toString() {
            return "Princess{" + "rate=" + rate + ", beauty=" + beauty + ", intellect=" + intellect + ", richness=" + richness + '}';
        }

 }
public static boolean contains(final int[] arr, final int key) {
    return Arrays.stream(arr).anyMatch(i -> i == key);
}
 static boolean isSubSequence(String str1, String str2, int m, int n)
    {

        if (m == 0)
            return true;
        if (n == 0)
            return false;

        if (str1.charAt(m-1) == str2.charAt(n-1))
            return isSubSequence(str1, str2, m-1, n-1);

        return isSubSequence(str1, str2, m, n-1);
    }

   public static void main (String []  args) throws IOException
    {
      Scanner s=new Scanner(System.in);
      int n=s.nextInt();long time=0;
      Integer [] arr=new Integer[n];Integer [] rra=new Integer[n];
        for (int i = 0; i < n; i++) {
            arr[i]=s.nextInt();
        }
        Arrays.sort(arr);
        rra= Arrays.copyOf(arr, arr.length);
        Arrays.sort(rra, Collections.reverseOrder());
        for (int i = 0; i < n; i++) {
            time+=arr[i]*rra[i];
        }
        if(time>=10007){time%=10007;}
        System.out.print(time);
    }
}


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import static java.util.Collections.list;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

/**
 *
 * @author george
 */
public class main {
 static boolean  isPrime(int n) {
    for(int i=2;i<n;i++) {
        if(n%i==0)
            return false;
    }
    return true;
}
static public class Princess{
 public int rate;public int beauty;public int intellect;public int richness;
 public Princess(int sum,int a,int b,int c){
  this.rate=sum;
  this.beauty=a;
  this.intellect=b;
  this.richness=c;
  }

        @Override
        public String toString() {
            return "Princess{" + "rate=" + rate + ", beauty=" + beauty + ", intellect=" + intellect + ", richness=" + richness + '}';
        }

 }
public static boolean contains(final int[] arr, final int key) {
    return Arrays.stream(arr).anyMatch(i -> i == key);
}
 static boolean isSubSequence(String str1, String str2, int m, int n)
    {

        if (m == 0)
            return true;
        if (n == 0)
            return false;

        if (str1.charAt(m-1) == str2.charAt(n-1))
            return isSubSequence(str1, str2, m-1, n-1);

        return isSubSequence(str1, str2, m, n-1);
    }

   public static void main (String []  args) throws IOException
    {
      Scanner s=new Scanner(System.in);
      int n=s.nextInt();long time=0;
      Integer [] arr=new Integer[n];Integer [] rra=new Integer[n];
        for (int i = 0; i < n; i++) {
            arr[i]=s.nextInt();
        }
        Arrays.sort(arr);
        rra= Arrays.copyOf(arr, arr.length);
        Arrays.sort(rra, Collections.reverseOrder());
        for (int i = 0; i < n; i++) {
            time+=arr[i]*rra[i];
        }
        if(time>=10007){time%=10007;}
        System.out.print(time);
    }
}


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import static java.util.Collections.list;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

/**
 *
 * @author george
 */
public class main {
 static boolean  isPrime(int n) {
    for(int i=2;i<n;i++) {
        if(n%i==0)
            return false;
    }
    return true;
}
static public class Princess{
 public int rate;public int beauty;public int intellect;public int richness;
 public Princess(int sum,int a,int b,int c){
  this.rate=sum;
  this.beauty=a;
  this.intellect=b;
  this.richness=c;
  }

        @Override
        public String toString() {
            return "Princess{" + "rate=" + rate + ", beauty=" + beauty + ", intellect=" + intellect + ", richness=" + richness + '}';
        }

 }
public static boolean contains(final int[] arr, final int key) {
    return Arrays.stream(arr).anyMatch(i -> i == key);
}
 static boolean isSubSequence(String str1, String str2, int m, int n)
    {

        if (m == 0)
            return true;
        if (n == 0)
            return false;

        if (str1.charAt(m-1) == str2.charAt(n-1))
            return isSubSequence(str1, str2, m-1, n-1);

        return isSubSequence(str1, str2, m, n-1);
    }

   public static void main (String []  args) throws IOException
    {
      Scanner s=new Scanner(System.in);
      Long n=s.nextLong();long time;time = 0;
      List<Long> arr=new ArrayList<Long>();

        for (long i = 0; i < n; i++) {
            arr.add(s.nextLong());
        }
        Collections.sort(arr);
         List<Long> rra=new ArrayList<Long>(arr);
        Collections.sort(rra, Collections.reverseOrder());
        for (int i = 0; i < n; i++) {
            time+=arr.get(i)*rra.get(i);
        }
        if(time>=10007){time%=10007;}
        System.out.print(time);
    }
}


import java.util.*;
import java.util.Arrays;

public class potionshomework{
	public static void main(String [] args){
		Scanner in=new Scanner(System.in);
			int n=in.nextInt();int i;long A[]=new long[n];long B[]=new long[n];

		for(i=0;i<n;i++){
			A[i]=in.nextInt();
		}

	Arrays.sort(A);
		for(i=0;i<n;i++)
			B[i]=A[n-i-1];
			long answer=0;
		for(i=0;i<n;i++)
			answer=(answer+(A[i]*B[i]))%10007;

	System.out.println(answer);

	}//end of main method
}//end  of main class


import java.util.Arrays;
import java.util.Scanner;

public class PotionsHomework {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		long ans = 0;
		int[] arr = new int[n];
		int[] arr2 = new int[n];
		for(int i = 0; i < n; i++){
			arr[i] = scan.nextInt();
			arr2[i] = arr[i];
		}
		Arrays.sort(arr);
		Arrays.sort(arr2);
		for(int i = 0, j = n-1; i < n; i++, j--){
			ans += (arr[i]*arr2[j])%10007;
		}
		System.out.println(ans%10007);
	}
}


import java.util.Scanner;

public class PotionsHomework {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		long ans = 0;
		int[] arr = new int[n];
		int[] arr2 = new int[n];
		for(int i = 0, j = n-1; i < n; i++, j--){
			arr[i] = scan.nextInt();
			arr2[j] = arr[i];
		}
		for(int i = 0; i < n; i++){
			ans += (arr[i]*arr2[i])%10007;
		}
		System.out.println(ans%10007);
	}
}


import java.util.Scanner;

public class PotionsHomework {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long n = scan.nextLong();
		long ans = 0;
		long[] arr = new long[(int)n];
		long[] arr2 = new long[(int)n];
		for(int i = 0, j = (int)n-1; i < (int)n; i++, j--){
			arr[i] = scan.nextLong();
			arr2[j] = arr[i];
		}
		for(int i = 0; i < n; i++){
			ans += (arr[i]*arr2[i]);
			ans %= 10007;
		}
		System.out.println(ans%10007);
	}
}


import java.util.Scanner;
import java.util.*;

public class PotionsHomework {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long n = scan.nextLong();
		long ans = 0;
		long[] arr = new long[(int)n];
		long[] arr2 = new long[(int)n];
		for(int i = 0, j = (int)n-1; i < (int)n; i++, j--){
			arr[i] = scan.nextLong();
			arr2[j] = arr[i];
		}
		Arrays.sort(arr);
		Arrays.sort(arr2);
		int ii = n-1;
		for(int i = 0; i < n; i++, ii--){
			ans += (arr[i]*arr2[ii]);
			ans %= 10007;
		}
		System.out.println(ans%10007);
	}
}


import java.util.Scanner;

public class PotionsHomework {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long n = scan.nextLong();
		long ans = 0;
		long[] arr = new long[n];
		long[] arr2 = new long[n];
		for(int i = 0, j = n-1; i < n; i++, j--){
			arr[i] = scan.nextLong();
			arr2[j] = arr[i];
		}
		for(int i = 0; i < n; i++){
			ans += (arr[i]*arr2[i]);
			ans %= 10007;
		}
		System.out.println(ans%10007);
	}
}


import java.util.Scanner;

public class PotionsHomework {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		long ans = 0;
		int[] arr = new int[n];
		int[] arr2 = new int[n];
		for(int i = 0, j = n-1; i < n; i++, j--){
			arr[i] = scan.nextInt();
			arr2[j] = arr[i];
		}
		for(int i = 0; i < n; i++){
			ans += (arr[i]*arr2[i]);
		}
		System.out.println(ans%10007);
	}
}


import java.util.Scanner;

public class PotionsHomework {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		long ans = 0;
		int[] arr = new int[n];
		int[] arr2 = new int[n];
		for(int i = 0, j = n-1; i < n; i++, j--){
			arr[i] = scan.nextInt();
			arr2[j] = arr[i];
		}
		for(int i = 0; i < n; i++){
			ans += (arr[i]*arr2[i]);
			ans %= 10007;
		}
		System.out.println(ans%10007);
	}
}


import java.util.Scanner;
import java.util.*;

public class PotionsHomework {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long n = scan.nextLong();
		long ans = 0;
		long[] arr = new long[(int)n];
		long[] arr2 = new long[(int)n];
		for(int i = 0, j = (int)n-1; i < (int)n; i++, j--){
			arr[i] = scan.nextLong();
			arr2[j] = arr[i];
		}
		Arrays.sort(arr);
		Arrays.sort(arr2);
		int ii = (int)n-1;
		for(int i = 0; i < n; i++, ii--){
			ans += (arr[i]*arr2[ii]);
			ans %= 10007;
		}
		System.out.println(ans%10007);
	}
}


import java.util.*;
import java.lang.*;

public class Problem {

	public static void main(String args[]) {
		//naive way
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();

		PriorityQueue<Integer> maxes = new PriorityQueue<Integer>(n);
		PriorityQueue<Integer> mins = new PriorityQueue<Integer>(n, Comparator.reverseOrder());

		//read input
		for (int i = 0; i < n; i++) {
			Integer x = scan.nextInt();
			maxes.add(x);
			mins.add(x);
		}

		Integer val = 0;
		while (maxes.size() > 0) {
			val += (maxes.poll() % 10007) * (mins.poll() % 10007);
			val = val % 10007;
		}

		System.out.print(val);

	}

}


import java.util.*;
import java.lang.*;

public class Problem {

	public static void main(String args[]) {
		//naive way
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();

		PriorityQueue<Integer> maxes = new PriorityQueue<Integer>(n);
		PriorityQueue<Integer> mins = new PriorityQueue<Integer>(n, Comparator.reverseOrder());

		//read input
		while (scan.hasNext()) {
			Integer x = scan.nextInt();
			maxes.add(x);
			mins.add(x);
		}

		Integer val = 0;
		while (maxes.size() > 0) {
			val += maxes.poll() * mins.poll();
			val = val % 10007;
		}

		System.out.print(val);

	}

}


import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.SortedSet;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 * #
 * @author pttrung
 */
public class C_Bubble9_Final {

    public static long MOD = 10007;

    public static void main(String[] args) throws FileNotFoundException {
        // PrintWriter out = new PrintWriter(new FileOutputStream(new File(
        // "output.txt")));
        PrintWriter out = new PrintWriter(System.out);
        Scanner in = new Scanner();
        int n = in.nextInt();
        long[]data = new long[n];
        for(int i = 0; i < n; i++){
        	data[i] = in.nextInt();
        }
        Arrays.sort(data);
        long result = 0;
        for(int i = 0; i < (n + 1)/2; i++){
        	int other = n - i - 1;
        	if(other != i){
        		result += (2*((data[i]*data[other]) % MOD)) % MOD;
        		result %= MOD;
        	}else{
        		result += (data[i]*data[other]) % MOD;
        		result %= MOD;
        	}
        }
        out.println(result);
        out.close();
    }

    public static int[] KMP(String val) {
        int i = 0;
        int j = -1;
        int[] result = new int[val.length() + 1];
        result[0] = -1;
        while (i < val.length()) {
            while (j >= 0 && val.charAt(j) != val.charAt(i)) {
                j = result[j];
            }
            j++;
            i++;
            result[i] = j;
        }
        return result;

    }

    public static boolean nextPer(int[] data) {
        int i = data.length - 1;
        while (i > 0 && data[i] < data[i - 1]) {
            i--;
        }
        if (i == 0) {
            return false;
        }
        int j = data.length - 1;
        while (data[j] < data[i - 1]) {
            j--;
        }
        int temp = data[i - 1];
        data[i - 1] = data[j];
        data[j] = temp;
        Arrays.sort(data, i, data.length);
        return true;
    }

    public static int digit(long n) {
        int result = 0;
        while (n > 0) {
            n /= 10;
            result++;
        }
        return result;
    }

    public static double dist(long a, long b, long x, long y) {
        double val = (b - a) * (b - a) + (x - y) * (x - y);
        val = Math.sqrt(val);
        double other = x * x + a * a;
        other = Math.sqrt(other);
        return val + other;

    }

    public static class Point implements Comparable<Point> {

        int x, y;

        public Point(int start, int end) {
            this.x = start;
            this.y = end;
        }

        @Override
        public int hashCode() {
            int hash = 5;
            hash = 47 * hash + this.x;
            hash = 47 * hash + this.y;
            return hash;
        }

        @Override
        public boolean equals(Object obj) {
            if (obj == null) {
                return false;
            }
            if (getClass() != obj.getClass()) {
                return false;
            }
            final Point other = (Point) obj;
            if (this.x != other.x) {
                return false;
            }
            if (this.y != other.y) {
                return false;
            }
            return true;
        }

        @Override
        public int compareTo(Point o) {
            return Integer.compare(x, o.x);
        }
    }

    public static class FT {

        long[] data;

        FT(int n) {
            data = new long[n];
        }

        public void update(int index, long value) {
            while (index < data.length) {
                data[index] += value;
                index += (index & (-index));
            }
        }

        public long get(int index) {
            long result = 0;
            while (index > 0) {
                result += data[index];
                index -= (index & (-index));
            }
            return result;

        }
    }

    public static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    public static long pow(long a, long b) {
        if (b == 0) {
            return 1;
        }
        if (b == 1) {
            return a;
        }
        long val = pow(a, b / 2);
        if (b % 2 == 0) {
            return val * val % MOD;
        } else {
            return val * (val * a % MOD) % MOD;

        }
    }

    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() throws FileNotFoundException {
            // System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
            //  br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("input.txt"))));
        }

        public String next() {

            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }

        public boolean endLine() {
            try {
                String next = br.readLine();
                while (next != null && next.trim().isEmpty()) {
                    next = br.readLine();
                }
                if (next == null) {
                    return true;
                }
                st = new StringTokenizer(next);
                return st.hasMoreTokens();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
    }
}


import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.SortedSet;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 * #
 * @author pttrung
 */
public class C_Bubble9_Final {

    public static long MOD = 10007;

    public static void main(String[] args) throws FileNotFoundException {
        // PrintWriter out = new PrintWriter(new FileOutputStream(new File(
        // "output.txt")));
        PrintWriter out = new PrintWriter(System.out);
        Scanner in = new Scanner();
        int n = in.nextInt();
        int[]data = new int[n];
        for(int i = 0; i < n; i++){
        	data[i] = in.nextInt();
        }
        Arrays.sort(data);
        long result = 0;
        for(int i = 0; i < (n + 1)/2; i++){
        	int other = n - i - 1;
        	if(other != i){
        		result += (2*((data[i]*data[other]) % MOD)) % MOD;
        		result %= MOD;
        	}else{
        		result += (data[i]*data[other]) % MOD;
        		result %= MOD;
        	}
        }
        out.println(result);
        out.close();
    }

    public static int[] KMP(String val) {
        int i = 0;
        int j = -1;
        int[] result = new int[val.length() + 1];
        result[0] = -1;
        while (i < val.length()) {
            while (j >= 0 && val.charAt(j) != val.charAt(i)) {
                j = result[j];
            }
            j++;
            i++;
            result[i] = j;
        }
        return result;

    }

    public static boolean nextPer(int[] data) {
        int i = data.length - 1;
        while (i > 0 && data[i] < data[i - 1]) {
            i--;
        }
        if (i == 0) {
            return false;
        }
        int j = data.length - 1;
        while (data[j] < data[i - 1]) {
            j--;
        }
        int temp = data[i - 1];
        data[i - 1] = data[j];
        data[j] = temp;
        Arrays.sort(data, i, data.length);
        return true;
    }

    public static int digit(long n) {
        int result = 0;
        while (n > 0) {
            n /= 10;
            result++;
        }
        return result;
    }

    public static double dist(long a, long b, long x, long y) {
        double val = (b - a) * (b - a) + (x - y) * (x - y);
        val = Math.sqrt(val);
        double other = x * x + a * a;
        other = Math.sqrt(other);
        return val + other;

    }

    public static class Point implements Comparable<Point> {

        int x, y;

        public Point(int start, int end) {
            this.x = start;
            this.y = end;
        }

        @Override
        public int hashCode() {
            int hash = 5;
            hash = 47 * hash + this.x;
            hash = 47 * hash + this.y;
            return hash;
        }

        @Override
        public boolean equals(Object obj) {
            if (obj == null) {
                return false;
            }
            if (getClass() != obj.getClass()) {
                return false;
            }
            final Point other = (Point) obj;
            if (this.x != other.x) {
                return false;
            }
            if (this.y != other.y) {
                return false;
            }
            return true;
        }

        @Override
        public int compareTo(Point o) {
            return Integer.compare(x, o.x);
        }
    }

    public static class FT {

        long[] data;

        FT(int n) {
            data = new long[n];
        }

        public void update(int index, long value) {
            while (index < data.length) {
                data[index] += value;
                index += (index & (-index));
            }
        }

        public long get(int index) {
            long result = 0;
            while (index > 0) {
                result += data[index];
                index -= (index & (-index));
            }
            return result;

        }
    }

    public static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    public static long pow(long a, long b) {
        if (b == 0) {
            return 1;
        }
        if (b == 1) {
            return a;
        }
        long val = pow(a, b / 2);
        if (b % 2 == 0) {
            return val * val % MOD;
        } else {
            return val * (val * a % MOD) % MOD;

        }
    }

    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() throws FileNotFoundException {
            // System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
            //  br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("input.txt"))));
        }

        public String next() {

            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }

        public boolean endLine() {
            try {
                String next = br.readLine();
                while (next != null && next.trim().isEmpty()) {
                    next = br.readLine();
                }
                if (next == null) {
                    return true;
                }
                st = new StringTokenizer(next);
                return st.hasMoreTokens();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
    }
}


/**
 * Created by qicodeng on 9/30/16.
 */

import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Codeforces_BubbleCup_9_PotionsHomework {
    public static void main(String[] args) {
        FScanner input = new FScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out), true);
        int count = input.nextInt();
        int[] student = new int[count];
        int[] lazy = new int[count];
        for (int i = 0; i < student.length; i++) {
            student[i] = input.nextInt();
        }
        Arrays.sort(student);
        for (int i = 0; i < lazy.length; i++) {
            lazy[i] = student[i];
        }
        long total = 0;
        int index = student.length - 1;
        for (int i = 0; i < student.length; i++) {
            int currentS = student[i];
            int currentL = lazy[index];
            index--;
            total += (currentS * currentL) % 10007;
        }
        out.println(total % 10007);
        out.close();
    }

    public static PrintWriter out;

    public static class FScanner {
        BufferedReader br;
        StringTokenizer st;

        public FScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        private String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


/**
 * Created by qicodeng on 9/30/16.
 */

import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Codeforces_BubbleCup_9_PotionsHomework {
    public static void main(String[] args) {
        FScanner input = new FScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out), true);
        int count = input.nextInt();
        int[] student = new int[count];
        int[] lazy = new int[count];
        for (int i = 0; i < student.length; i++) {
            student[i] = input.nextInt();
        }
        Arrays.sort(student);
        for (int i = 0; i < lazy.length; i++) {
            lazy[i] = student[i];
        }
        long total = 0;
        int index = student.length - 1;
        for (int i = 0; i < student.length; i++) {
            int currentS = student[i];
            int currentL = lazy[index];
            index--;
            total += (currentS * currentL);
        }
        out.println(total % 10007);
        out.close();
    }

    public static PrintWriter out;

    public static class FScanner {
        BufferedReader br;
        StringTokenizer st;

        public FScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        private String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


/**
 * Created by qicodeng on 9/30/16.
 */

import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Codeforces_BubbleCup_9_PotionsHomework {
    public static void main(String[] args) {
        FScanner input = new FScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out), true);
        int count = input.nextInt();
        int[] diff = new int[count];
        int[] lazy = new int[count];
        for (int i = 0; i < diff.length; i++) {
            diff[i] = input.nextInt();
        }
        Arrays.sort(diff);
        for (int i = 0; i < lazy.length; i++) {
            lazy[i] = diff[lazy.length - 1 - i];
        }
        long answer = 0;
        for (int i = 0; i < lazy.length; i++) {
            answer += ((lazy[i] * diff[i]) % 10007);
        }
        out.println(answer % 10007);
        out.close();
    }

    public static PrintWriter out;

    public static class FScanner {
        BufferedReader br;
        StringTokenizer st;

        public FScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        private String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


/**
 * Created by qicodeng on 9/30/16.
 */

import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Codeforces_BubbleCup_9_PotionsHomework {
    public static void main(String[] args) {
        FScanner input = new FScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out), true);
        int count = input.nextInt();
        long[] diff = new long[count];
        long[] lazy = new long[count];
        for (int i = 0; i < diff.length; i++) {
            diff[i] = input.nextLong();
        }
        Arrays.sort(diff);
        for (int i = 0; i < lazy.length; i++) {
            lazy[i] = diff[lazy.length - 1 - i];
        }
        long answer = 0;
        for (int i = 0; i < lazy.length; i++) {
            answer += ((lazy[i] * diff[i]) % 10007);
        }
        out.println(answer % 10007);
        out.close();
    }

    public static PrintWriter out;

    public static class FScanner {
        BufferedReader br;
        StringTokenizer st;

        public FScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        private String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


/**
 * Created by qicodeng on 9/30/16.
 */

import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Codeforces_BubbleCup_9_PotionsHomework {
    public static void main(String[] args) {
        FScanner input = new FScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out), true);
        int count = input.nextInt();
        int[] student = new int[count];
        int[] lazy = new int[count];
        for (int i = 0; i < student.length; i++) {
            student[i] = input.nextInt();
        }
        Arrays.sort(student);
        for (int i = 0; i < lazy.length; i++) {
            lazy[i] = student[i];
        }
        long total = 0;
        int index = student.length - 1;
        for (int i = 0; i < student.length; i++) {
            int currentS = student[i];
            int currentL = lazy[index];
            index--;
            total += (currentS * currentL) % 10007;
        }
        out.println(total);
        out.close();
    }

    public static PrintWriter out;

    public static class FScanner {
        BufferedReader br;
        StringTokenizer st;

        public FScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        private String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


import java.util.*;
import java.util.Arrays;

public class p717c{
public static void main(String [] args){
Scanner in=new Scanner(System.in);
int n=in.nextInt();int i;long A[]=new long[n];long B[]=new long[n];
for(i=0;i<n;i++)
{
A[i]=in.nextInt();
}
Arrays.sort(A);
for(i=0;i<n;i++)
B[i]=A[n-i-1];
long answer=0;
for(i=0;i<n;i++)
answer=(answer+(A[i]*B[i]))%10007;

System.out.println(answer);
}

}


import java.util.*;
import java.util.Arrays;

public class p717c{
public static void main(String [] args){
Scanner in=new Scanner(System.in);
int n=in.nextInt();int i;int A[]=new int[n];int B[]=new int[n];
for(i=0;i<n;i++)
{
A[i]=in.nextInt();
}
Arrays.sort(A);
for(i=0;i<n;i++)
B[i]=A[n-i-1];
int answer=0;
for(i=0;i<n;i++)
answer=(answer+((A[i]*B[i])%10007))%10007;

System.out.println(answer);
}

}


import java.util.*;
import java.util.Arrays;
public class homework
{
    public static void main(String args[])
    {
        Scanner ex=new Scanner(System.in);
        int n=ex.nextInt();
        long dif[]=new long[n];
        long time=0;
        for(int i=0;i<n;i++)
        dif[i]=ex.nextLong();
        Arrays.sort(dif);
        for(int i=0;i<n;i++)
        time=(time+dif[i]*dif[n-i-1])%10007;
        System.out.println(time);
    }
}


import java.util.*;
import java.util.Arrays;
public class homework
{
    public static void main(String args[])
    {
        Scanner ex=new Scanner(System.in);
        int n=ex.nextInt();
        long dif[]=new long[n];
        long time=0;
        for(int i=0;i<n;i++)
        dif[i]=ex.nextLong();
        Arrays.sort(dif);
        for(int i=0;i<n;i++)
        time=time+dif[i]*dif[n-i-1];
        System.out.println(time);
    }
}


import java.io.*;
import java.util.*;

public class C717
{
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);

		int n = in.nextInt();
		long a=0;

		long[] lLevel = new long[n];
		long[] dLevel = new long[n];

		for(int i=0;i<n;i++)
		{
			a = in.nextLong();

			lLevel[i] = a;
			dLevel[i] = -a;
		}
		a = 0;

		Arrays.sort(lLevel);
		Arrays.sort(dLevel);

		for(int i=0;i<n;i++)
		{
			a += (-1*lLevel[i]*dLevel[i])%10007;
			a %= 10007;
		}

		System.out.println(a);
	}

}


import java.io.*;
import java.util.*;

public class C717
{
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);

		int n = in.nextInt();
		int a=0;

		int[] lLevel = new int[n];
		int[] dLevel = new int[n];

		for(int i=0;i<n;i++)
		{
			a = in.nextInt();

			lLevel[i] = a;
			dLevel[i] = -a;
		}
		a = 0;

		Arrays.sort(lLevel);
		Arrays.sort(dLevel);

		for(int i=0;i<n;i++)
		{
			a += (-1*lLevel[i]*dLevel[i])%10007;
			a %= 10007;
		}

		System.out.println(a);
	}

}


import java.io.*;
import java.util.*;

public class C717
{
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);

		int n = in.nextInt();
		long a=0;

		int[] lLevel = new int[n];
		int[] dLevel = new int[n];

		for(int i=0;i<n;i++)
		{
			a = in.nextLong();

			lLevel[i] = (int)a;
			dLevel[i] = (int)-a;
		}
		a = 0;

		Arrays.sort(lLevel);
		Arrays.sort(dLevel);

		for(int i=0;i<n;i++)
		{
			a += (-1*lLevel[i]*dLevel[i])%10007;
			a %= 10007;
		}

		System.out.println(a);
	}

}


import java.io.*;
import java.util.*;

public class C717
{
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);

		int n = in.nextInt();
		int a=0;

		int[] lLevel = new int[n];
		int[] dLevel = new int[n];

		for(int i=0;i<n;i++)
		{
			a = in.nextInt();

			lLevel[i] = a;
			dLevel[i] = -a;
		}
		a = 0;

		Arrays.sort(lLevel);
		Arrays.sort(dLevel);

		for(int i=0;i<n;i++)
		{
			a += (-1*lLevel[i]*dLevel[i])%10007;
		}

		System.out.println(a);
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class C717 {

	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static int n, ans;
	static int[] a;

	public static void main(String[] args) throws NumberFormatException, IOException {
		n = Integer.parseInt(br.readLine());
		a = new int[n];

		for (int i = 0; i < n; i++)
			a[i] = Integer.parseInt(br.readLine());

		Arrays.sort(a);

		for (int i = 0; i < n; i++) {
			ans += ((a[i] % 10007) * (a[n - i - 1] % 10007)) % 10007;
			ans %= 10007;
		}

		System.out.println(ans);

	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class C717 {

	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static int n, ans;
	static int[] a;

	public static void main(String[] args) throws NumberFormatException, IOException {
		n = Integer.parseInt(br.readLine());
		a = new int[n];

		for (int i = 0; i < n; i++)
			a[i] = Integer.parseInt(br.readLine());

		Arrays.sort(a);

		for (int i = 0; i <= n / 2; i++) {
			ans += ((a[i] % 10007) * (a[n - i - 1] % 10007)) % 10007;
			ans %= 10007;
		}

		System.out.println(ans);

	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class C717 {

	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static int n, ans;
	static int[] a;

	public static void main(String[] args) throws NumberFormatException, IOException {
		n = Integer.parseInt(br.readLine());
		a = new int[n];

		for (int i = 0; i < n; i++)
			a[i] = Integer.parseInt(br.readLine());

		for (int i = 0; i <= n / 2; i++) {
			ans += ((a[i] % 10007) * (a[n - i - 1] % 10007)) % 10007;
			ans %= 10007;
		}

		System.out.println(ans);

	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class C717 {

	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static int n, ans;
	static long cur;
	static int[] a;

	public static void main(String[] args) throws NumberFormatException, IOException {
		n = Integer.parseInt(br.readLine());
		a = new int[n];

		for (int i = 0; i < n; i++)
			a[i] = Integer.parseInt(br.readLine());

		Arrays.sort(a);

		for (int i = 0; i <= n / 2; i++) {
			cur = a[i]*a[n-i-1];
			cur %= 10007;
//			ans += ((a[i] % 10007) * (a[n - i - 1] % 10007)) % 10007;
			ans += cur;
		}

		System.out.println(ans);

	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class C717 {

	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static int n, ans;
	static int[] a;

	public static void main(String[] args) throws NumberFormatException, IOException {
		n = Integer.parseInt(br.readLine());
		a = new int[n];

		for(int i = 0;i<n ;i++)
			a[i]=Integer.parseInt(br.readLine());

		for(int i = 0;i<=n/2;i++){
			ans += a[i]*a[n-i-1];
			ans %= 10007;
		}

		System.out.println(ans);

	}

}


import java.util.Arrays;
import java.util.Scanner;

public class _717C {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n];
		for (int i = 0; i < n; i++) a[i] = sc.nextInt();
		Arrays.sort(a);
		long r = 0;
		for (int i = 0; i < n; i++) {
			r += a[i] * a[n - i - 1];
			r %= 10_007;
		}
		System.out.println(r);
	}
}


import java.util.Arrays;
import java.util.Scanner;

public class _717C {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) a[i] = sc.nextInt();
		Arrays.sort(a);
		int r = 0;
		for (int i = 0; i < n; i++) {
			r += a[i] * a[n - i - 1];
			r %= 10_007;
		}
		System.out.println(r);
	}
}


import java.util.Arrays;
import java.util.Scanner;

public class C717 {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        Long[] A = new Long[N];
        for (int n=0; n<N; n++) {
            A[n] = in.nextLong();
        }
        Arrays.sort(A);
        long mod = 10007;
        long answer = 0;
        for (int n=0; n<N; n++) {
            answer += A[n]*A[N-1-n];
            answer %= mod;
        }
        System.out.println(answer);
    }

}


import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Potions {
	public static void main(String[] args) {
		MyScanner sc = new MyScanner();
		out = new PrintWriter(new BufferedOutputStream(System.out));

		// Start writing your solution here.
		// -------------------------------------

		int n = sc.nextInt(); // read input as integer
		int[] students = new int[n];
		for (int i = 0; i < n; i++) {
			students[i] = sc.nextInt();
		}
		Arrays.sort(students);
		int[] tasks = new int[n];
		for (int i = 0; i < n; i++) {
			tasks[i] = students[n - (i + 1)];
		}
		int sum = 0;
		for (int i = 0; i < n; i++) {
			sum += students[i] * tasks[i];
		}
		/*
		 * long k = sc.nextLong(); // read input as long
		 * double d = sc.nextDouble(); // read input as double
		 * String str = sc.next(); // read input as String
		 * String s = sc.nextLine(); // read whole line as String
		 *
		 * int result = 3*n;
		 */
		out.println(sum % 10007); // print via PrintWriter

		// Stop writing your solution here.
		// -------------------------------------
		out.close();
	}

	// -----------PrintWriter for faster output---------------------------------
	public static PrintWriter out;

	// -----------MyScanner class for faster input----------
	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}
	// --------------------------------------------------------
}


import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Potions {
	public static void main(String[] args) {
		MyScanner sc = new MyScanner();
		out = new PrintWriter(new BufferedOutputStream(System.out));

		// Start writing your solution here.
		// -------------------------------------

		int n = sc.nextInt(); // read input as integer
		int[] students = new int[n];
		for (int i = 0; i < n; i++) {
			students[i] = sc.nextInt();
		}
		Arrays.sort(students);
		int[] tasks = new int[n];
		for (int i = 0; i < n; i++) {
			tasks[i] = students[n - (i + 1)];
		}
		int sum = 0;
		for (int i = 0; i < n; i++) {
			sum += students[i] * tasks[i];
		}
		/*
		 * long k = sc.nextLong(); // read input as long
		 * double d = sc.nextDouble(); // read input as double
		 * String str = sc.next(); // read input as String
		 * String s = sc.nextLine(); // read whole line as String
		 *
		 * int result = 3*n;
		 */
		out.println(sum); // print via PrintWriter

		// Stop writing your solution here.
		// -------------------------------------
		out.close();
	}

	// -----------PrintWriter for faster output---------------------------------
	public static PrintWriter out;

	// -----------MyScanner class for faster input----------
	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}
	// --------------------------------------------------------
}


import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Potions {
	public static void main(String[] args) {
		MyScanner sc = new MyScanner();
		out = new PrintWriter(new BufferedOutputStream(System.out));

		// Start writing your solution here.
		// -------------------------------------

		int n = sc.nextInt(); // read input as integer
		int[] students = new int[n];
		for (int i = 0; i < n; i++) {
			students[i] = sc.nextInt();
		}
		Arrays.sort(students);
		int[] tasks = new int[n];
		for (int i = 0; i < n; i++) {
			tasks[i] = students[n - (i + 1)];
		}
		int sum = 0;
		for (int i = 0; i < n; i++) {
			sum += ((students[i] % 10007) * (tasks[i] % 10007)) % 10007;
		}

		/*
		 * long k = sc.nextLong(); // read input as long
		 * double d = sc.nextDouble(); // read input as double
		 * String str = sc.next(); // read input as String
		 * String s = sc.nextLine(); // read whole line as String
		 *
		 * int result = 3*n;
		 */
		out.println(sum % 10007); // print via PrintWriter

		// Stop writing your solution here.
		// -------------------------------------
		out.close();
	}

	// -----------PrintWriter for faster output---------------------------------
	public static PrintWriter out;

	// -----------MyScanner class for faster input----------
	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}
	// --------------------------------------------------------
}


import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Potions {
	public static void main(String[] args) {
		MyScanner sc = new MyScanner();
		out = new PrintWriter(new BufferedOutputStream(System.out));

		// Start writing your solution here.
		// -------------------------------------

		int n = sc.nextInt(); // read input as integer
		int[] students = new int[n];
		for (int i = 0; i < n; i++) {
			students[i] = sc.nextInt();
		}
		Arrays.sort(students);
		int[] tasks = new int[n];
		for (int i = 0; i < n; i++) {
			tasks[i] = students[n - (i + 1)];
		}
		int sum = 0;
		for (int i = 0; i < n; i++) {
			sum += (students[i] * tasks[i]) % 10007;
		}
		/*
		 * long k = sc.nextLong(); // read input as long
		 * double d = sc.nextDouble(); // read input as double
		 * String str = sc.next(); // read input as String
		 * String s = sc.nextLine(); // read whole line as String
		 *
		 * int result = 3*n;
		 */
		out.println(sum % 10007); // print via PrintWriter

		// Stop writing your solution here.
		// -------------------------------------
		out.close();
	}

	// -----------PrintWriter for faster output---------------------------------
	public static PrintWriter out;

	// -----------MyScanner class for faster input----------
	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}
	// --------------------------------------------------------
}


import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class CBubbleCup_717 {
	public static void main(String args[]) throws FileNotFoundException {
		InputReader in = new InputReader(System.in);
		OutputStream outputStream = System.out;
		PrintWriter out = new PrintWriter(outputStream);
		StringBuilder sb = new StringBuilder();
		// ----------My Code----------
		int n = in.nextInt();
		long a[] = new long[n];
		long b[] = new long[n];
		a=in.nextLongArray(n, 0);
		Arrays.sort(a);

		for (int i = 0; i < n; i++)
			b[i] = a[n - i - 1];

		long ans = 0;

		for (int i = 0; i < n; i++)
			ans = (ans + (a[i] * b[i])) % 10007;

		System.out.println(ans);
		// ---------------The End------------------

		out.close();
	}

	// ---------------Extra Methods------------------

	public static long pow(long x, long n, long mod) {
		long res = 1;
		x %= mod;
		while (n > 0) {
			if (n % 2 == 1) {
				res = (res * x) % mod;
			}
			x = (x * x) % mod;
			n /= 2;
		}
		return res;
	}

	public static boolean isPal(String s) {
		for (int i = 0, j = s.length() - 1; i <= j; i++, j--) {
			if (s.charAt(i) != s.charAt(j))
				return false;
		}
		return true;
	}

	public static String rev(String s) {
		StringBuilder sb = new StringBuilder(s);
		sb.reverse();
		return sb.toString();
	}

	public static long gcd(long x, long y) {
		if (x % y == 0)
			return y;
		else
			return gcd(y, x % y);
	}

	public static int gcd(int x, int y) {
		if (x % y == 0)
			return y;
		else
			return gcd(y, x % y);
	}

	public static long gcdExtended(long a, long b, long[] x) {

		if (a == 0) {
			x[0] = 0;
			x[1] = 1;
			return b;
		}
		long[] y = new long[2];
		long gcd = gcdExtended(b % a, a, y);

		x[0] = y[1] - (b / a) * y[0];
		x[1] = y[0];

		return gcd;
	}

	public static int abs(int a, int b) {
		return (int) Math.abs(a - b);
	}

	public static long abs(long a, long b) {
		return (long) Math.abs(a - b);
	}

	public static int max(int a, int b) {
		if (a > b)
			return a;
		else
			return b;
	}

	public static int min(int a, int b) {
		if (a > b)
			return b;
		else
			return a;
	}

	public static long max(long a, long b) {
		if (a > b)
			return a;
		else
			return b;
	}

	public static long min(long a, long b) {
		if (a > b)
			return b;
		else
			return a;
	}
	// ---------------Extra Methods------------------

	public static void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream inputstream) {
			reader = new BufferedReader(new InputStreamReader(inputstream));
			tokenizer = null;
		}

		public String nextLine() {
			String fullLine = null;
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					fullLine = reader.readLine();
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
				return fullLine;
			}
			return fullLine;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public char nextChar() {
			return next().charAt(0);
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n, int f) {
			if (f == 0) {
				int[] arr = new int[n];
				for (int i = 0; i < n; i++) {
					arr[i] = nextInt();
				}
				return arr;
			} else {
				int[] arr = new int[n + 1];
				for (int i = 1; i < n + 1; i++) {
					arr[i] = nextInt();
				}
				return arr;
			}
		}

		public long[] nextLongArray(int n, int f) {
			if (f == 0) {
				long[] arr = new long[n];
				for (int i = 0; i < n; i++) {
					arr[i] = nextLong();
				}
				return arr;
			} else {
				long[] arr = new long[n + 1];
				for (int i = 1; i < n + 1; i++) {
					arr[i] = nextLong();
				}
				return arr;
			}

		}

		public double[] nextDoubleArray(int n, int f) {
			if (f == 0) {
				double[] arr = new double[n];
				for (int i = 0; i < n; i++) {
					arr[i] = nextDouble();
				}
				return arr;
			} else {
				double[] arr = new double[n + 1];
				for (int i = 1; i < n + 1; i++) {
					arr[i] = nextDouble();
				}
				return arr;
			}
		}

	}

	static class Pair implements Comparable<Pair> {
		int a, b;

		Pair(int a, int b) {
			this.a = a;
			this.b = b;
		}

		public int compareTo(Pair o) {
			// TODO Auto-generated method stub
			if (this.a != o.a)
				return Integer.compare(this.a, o.a);
			else
				return Integer.compare(this.b, o.b);
		}

		public boolean equals(Object o) {
			if (o instanceof Pair) {
				Pair p = (Pair) o;
				return p.a == a && p.b == b;
			}
			return false;
		}

		public int hashCode() {
			return new Integer(a).hashCode() * 31 + new Integer(b).hashCode();
		}

	}

}


import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class CBubbleCup_717 {
	public static void main(String args[]) throws FileNotFoundException {
		InputReader in = new InputReader(System.in);
		OutputStream outputStream = System.out;
		PrintWriter out = new PrintWriter(outputStream);
		StringBuilder sb = new StringBuilder();
		// ----------My Code----------
		int n = in.nextInt();
		long a[] = new long[n];
		long b[] = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = in.nextInt();
		}

		Arrays.sort(a);

		for (int i = 0; i < n; i++)
			b[i] = a[n - i - 1];

		long ans = 0;

		for (int i = 0; i < n; i++)
			ans = (ans + (a[i] * b[i])) % 10007;

		System.out.println(ans);
		// ---------------The End------------------

		out.close();
	}

	// ---------------Extra Methods------------------

	public static long pow(long x, long n, long mod) {
		long res = 1;
		x %= mod;
		while (n > 0) {
			if (n % 2 == 1) {
				res = (res * x) % mod;
			}
			x = (x * x) % mod;
			n /= 2;
		}
		return res;
	}

	public static boolean isPal(String s) {
		for (int i = 0, j = s.length() - 1; i <= j; i++, j--) {
			if (s.charAt(i) != s.charAt(j))
				return false;
		}
		return true;
	}

	public static String rev(String s) {
		StringBuilder sb = new StringBuilder(s);
		sb.reverse();
		return sb.toString();
	}

	public static long gcd(long x, long y) {
		if (x % y == 0)
			return y;
		else
			return gcd(y, x % y);
	}

	public static int gcd(int x, int y) {
		if (x % y == 0)
			return y;
		else
			return gcd(y, x % y);
	}

	public static long gcdExtended(long a, long b, long[] x) {

		if (a == 0) {
			x[0] = 0;
			x[1] = 1;
			return b;
		}
		long[] y = new long[2];
		long gcd = gcdExtended(b % a, a, y);

		x[0] = y[1] - (b / a) * y[0];
		x[1] = y[0];

		return gcd;
	}

	public static int abs(int a, int b) {
		return (int) Math.abs(a - b);
	}

	public static long abs(long a, long b) {
		return (long) Math.abs(a - b);
	}

	public static int max(int a, int b) {
		if (a > b)
			return a;
		else
			return b;
	}

	public static int min(int a, int b) {
		if (a > b)
			return b;
		else
			return a;
	}

	public static long max(long a, long b) {
		if (a > b)
			return a;
		else
			return b;
	}

	public static long min(long a, long b) {
		if (a > b)
			return b;
		else
			return a;
	}
	// ---------------Extra Methods------------------

	public static void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream inputstream) {
			reader = new BufferedReader(new InputStreamReader(inputstream));
			tokenizer = null;
		}

		public String nextLine() {
			String fullLine = null;
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					fullLine = reader.readLine();
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
				return fullLine;
			}
			return fullLine;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public char nextChar() {
			return next().charAt(0);
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n, int f) {
			if (f == 0) {
				int[] arr = new int[n];
				for (int i = 0; i < n; i++) {
					arr[i] = nextInt();
				}
				return arr;
			} else {
				int[] arr = new int[n + 1];
				for (int i = 1; i < n + 1; i++) {
					arr[i] = nextInt();
				}
				return arr;
			}
		}

		public long[] nextLongArray(int n, int f) {
			if (f == 0) {
				long[] arr = new long[n];
				for (int i = 0; i < n; i++) {
					arr[i] = nextLong();
				}
				return arr;
			} else {
				long[] arr = new long[n + 1];
				for (int i = 1; i < n + 1; i++) {
					arr[i] = nextLong();
				}
				return arr;
			}

		}

		public double[] nextDoubleArray(int n, int f) {
			if (f == 0) {
				double[] arr = new double[n];
				for (int i = 0; i < n; i++) {
					arr[i] = nextDouble();
				}
				return arr;
			} else {
				double[] arr = new double[n + 1];
				for (int i = 1; i < n + 1; i++) {
					arr[i] = nextDouble();
				}
				return arr;
			}
		}

	}

	static class Pair implements Comparable<Pair> {
		int a, b;

		Pair(int a, int b) {
			this.a = a;
			this.b = b;
		}

		public int compareTo(Pair o) {
			// TODO Auto-generated method stub
			if (this.a != o.a)
				return Integer.compare(this.a, o.a);
			else
				return Integer.compare(this.b, o.b);
		}

		public boolean equals(Object o) {
			if (o instanceof Pair) {
				Pair p = (Pair) o;
				return p.a == a && p.b == b;
			}
			return false;
		}

		public int hashCode() {
			return new Integer(a).hashCode() * 31 + new Integer(b).hashCode();
		}

	}

}


package sort;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc=new Scanner(System.in);

		int n=sc.nextInt();
		ArrayList<Integer> a=new ArrayList<Integer>(n);
		//System.out.println("mn");
		for(int i=0;i<n;i++)
		{
			int t=sc.nextInt();
			a.add(t);
		}
		//System.out.println("lm");
		Collections.sort(a);
	int ans=0;
		for(int i=0;i<a.size();i++)
	        ans+=(((a.get(i)*a.get(n-i-1))%10007));
		System.out.println(ans);
	}

}