#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //int:2*10**9
typedef long double ld;
typedef pair<ll,ll> P;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define MOD 1000000007 //998244353
#define PI 3.141592653
#define INF 100000000000000 //14
//cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    REP(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    ll ans = a[0]+1;
    FOR(i,1,n-1) {
        ans = (ans*(a[i]-a[i-1]+1))%MOD;
    }
    cout << ans << endl;
    return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define per(i, a, b) for (int i = a; i >= b; i--)
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
typedef long long LL;
typedef pair <int, int> P;
const int N = 2e5 + 5;

int n, a[N], b[N], c[N];
LL ans, res;

int main() {
	cin>>n;
	rep (i, 1, n) scanf("%d", &a[i]), ans += a[i];
	rep (i, 1, n) scanf("%d", &b[i]), b[i] -= a[i];
	rep (i, 1, n) {
		if (i&1) b[(i + 1)>>1] = b[i];
		else c[i>>1] = b[i]; 
	} 
	sort(b + 1, b + n/2 + 1);
	sort(c + 1, c + n/2 + 1);
	res = ans;
	per (i, n/2, 1) res += b[i] + c[i], ans = max(ans, res);
	printf("%lld\n", ans);
}
