//https://atcoder.jp/contests/agc048/tasks/agc048_b
//B - Bracket Score
#include <bits/stdc++.h>
 
using namespace std;
 
const int MAXN=2e5+4;
long long a[MAXN];
long long b[MAXN];
 
int main() {
    ios::sync_with_stdio(false);
 
    int n;
    cin>>n;
    for (int i=1; i<=n; i++) {
        cin>>a[i];
    }
    for (int i=1; i<=n; i++) {
        cin>>b[i];
        if (0==i%2) {
            swap(a[i], b[i]);
        }
    }
 
    long long ans=0;
    for (int i=1; i<=n; i++) {
        ans+=a[i];
        b[i]-=a[i];
    }
    sort(b+1, b+n+1, greater<int>());//降序
    for (int i=1; i<=n/2; i++) {
        ans+=b[i];
    }
 
    cout<<ans<<"\n";
 
    return 0;
}
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
#define f(i,a,b) for( int i=a;i<=b;++i)
#define ff(i,a,b) for( int i=a;i>=b;--i)
#define debug(x) cerr << #x << " : " << x << " " << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
const ll mod = 1e9 + 7;
const ll mod2 = 998244353;
const ll inf = 2e18;
const double tiaohe = 0.57721566490153286060651209;
ll oula(ll x) { ll res = x;f(i, 2, x / i) { if (x % i == 0) { res = res / i * (i - 1);while (x % i == 0) x /= i; } }if (x > 1) res = res / x * (x - 1);return res; }
ll quickmod(ll a, ll n, ll m) { ll s = 1;while (n) { if (n & 1) { s = s * a % m; }a = (a*a) % m;n = n / 2; }return s; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
void ex_gcd(ll a, ll b, ll &x, ll &y, ll &d) { if (!b) { d = a, x = 1, y = 0; } else { ex_gcd(b, a % b, y, x, d);y -= x * (a / b); } }
ll inv(ll t, ll p) { ll d, x, y;ex_gcd(t, p, x, y, d);return d == 1 ? (x % p + p) % p : -1; }
bool isPrime(ll x) { if (x == 2)return true;if (x % 2 == 0)return false;for (ll i = 2;i*i <= x;i++) if (x % i == 0)return false; return true; }
inline ll in() { char ch = getchar();ll x = 0, f = 1;while (ch<'0' || ch>'9') { if (ch == '-')f = -1;ch = getchar(); }while (ch >= '0'&&ch <= '9') { x = x * 10 + ch - '0';ch = getchar(); }return x * f; }
void print(double x) { printf("%.6lf\n", x); }
//double a = log(n) +tiaohe + 1.0 / (2 * n);
double eqa = (1 + sqrt(5.0)) / 2.0;
double E = 2.7182818284;
const double eps = 1e-10;
const int N = 6e5 + 100;
ll a[N];
int main()
{
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
#endif
	int n;
	cin >> n;
	f(i, 1, n)a[i] = in();
	ll ans = 0;
	ll pre = 0, sum = 0;
	sort(a + 1, a + 1 + n);
	f(i, 1, n) {
		sum = sum * 2 % mod2;
		ll nx = (sum + pre) % mod2;
		ll tmp = (sum + pre+a[i]) % mod2;
		ans = (ans + tmp * a[i] % mod2) % mod2;
		pre = a[i];
		sum = nx;
	}
	cout << ans << endl;
	return 0;
}