#include <bits/stdc++.h>
#define double long double
#define int long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int, int> pi;
const int MOD=1000000007;
int gcd(int a, int b) {return (b==0? a: gcd(b, a%b));}
int lcm(int a, int b) {return a*b/gcd(a, b);}
void yes() {cout << "YES\n"; return;}
void no() {cout << "NO\n"; return;}
int to(string s){
int n=s.size();
int i=0;
while(i<n && s[i]=='0') i++;
int cnt=s[i]-'0';
for(i=i+1; i<s.size(); i++){
cnt*=s[i]-'0';
}
return cnt;
}
void solve() {
int n;
cin >> n;
vector<int> t1(n), t2(n);
for(int i=0; i<n; i++){
cin >> t1[i];
t2[i]=t1[i];
}
int cnt=0;
sort(t1.begin(), t1.end());
sort(t2.rbegin(), t2.rend());
for(int i=0; i<n; i++){
cnt+=t1[i]*t2[i];
cnt%=10007;
}
cout << cnt << "\n";
}
signed main() {
cin.tie(0)->sync_with_stdio(0);
srand(time(0));
int t=1;
// cin >> t;
//sieve(1e7);
while(t--){
solve();
}
}
130. Surrounded Regions | 129. Sum Root to Leaf Numbers |
120. Triangle | 102. Binary Tree Level Order Traversal |
96. Unique Binary Search Trees | 75. Sort Colors |
74. Search a 2D Matrix | 71. Simplify Path |
62. Unique Paths | 50. Pow(x, n) |
43. Multiply Strings | 34. Find First and Last Position of Element in Sorted Array |
33. Search in Rotated Sorted Array | 17. Letter Combinations of a Phone Number |
5. Longest Palindromic Substring | 3. Longest Substring Without Repeating Characters |
1312. Minimum Insertion Steps to Make a String Palindrome | 1092. Shortest Common Supersequence |
1044. Longest Duplicate Substring | 1032. Stream of Characters |
987. Vertical Order Traversal of a Binary Tree | 952. Largest Component Size by Common Factor |
212. Word Search II | 174. Dungeon Game |
127. Word Ladder | 123. Best Time to Buy and Sell Stock III |
85. Maximal Rectangle | 84. Largest Rectangle in Histogram |
60. Permutation Sequence | 42. Trapping Rain Water |