#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<int, int> pi;

const int maxn = 2e5 + 5;

int n;
ll a[2 * maxn];

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    for(int i = 1;i <= 2 * n;i++){
        cin >> a[i];
    }
    multiset<ll> s;
    ll ans = 0;
    for(int i = n;i >= 1;i--){
        s.insert(a[i]);
        ans += a[i];
        if(a[2 * n + 1 - i] > *s.begin()){
            ans += (a[2 * n + 1 - i] - (*s.begin()));
            s.erase(s.begin()); 
            s.insert(a[2 * n + 1 - i]); 
        }
    }
    cout << ans << endl;
    return 0;
}

#include <bits/stdc++.h>

constexpr int MOD = 1e9 + 7;

using namespace std;

int main() {
  int N;
  cin >> N;
  
  vector<long long> A(N + 1, 0);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  
  long long ans = 1;
  
  for (int i = 0; i < N; i++) {
    ans *= A[i + 1] - A[i] + 1;
    ans %= MOD;
  }
  
  cout << ans << endl;
  
  return 0;
}