#include <cstdio>
#include <queue>
using namespace std;

int main(){
	int n;
	scanf("%d", &n);
	vector<int> a(n*2);
	for(int& i: a)
		scanf("%d", &i);
	priority_queue<int> q;
	long long ans=0;
	for(int i = 0;i < n;i ++){
		q.push(a[i]);
		q.push(a[n*2-1-i]);
		ans+=q.top();
		q.pop();
	}
	printf("%lld\n", ans);
}
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const int mod = 1000000007;
const int Maxn = 100005;

int n;
int a[Maxn];

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	sort(a, a + n + 1);
	int res = 1;
	for (int i = 1; i <= n; i++)
		res = ll(res) * (a[i] - a[i - 1] + 1) % mod;
	printf("%d\n", res);
    return 0;
}
