You are given two arrays a and b, both of length n.

Let's define a function f(l, r) = ∑_{l ≤ i ≤ r} a_i ⋅ b_i.

Your task is to reorder the elements (choose an arbitrary order of elements) of the array b to minimize the value of ∑_{1 ≤ l ≤ r ≤ n} f(l, r). Since the answer can be very large, you have to print it modulo 998244353. Note that you should minimize the answer but not its remainder.

Input

The first line of the input contains one integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the number of elements in a and b.

The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^6), where a_i is the i-th element of a.

The third line of the input contains n integers b_1, b_2, ..., b_n (1 ≤ b_j ≤ 10^6), where b_j is the j-th element of b.

Output

Print one integer — the minimum possible value of ∑_{1 ≤ l ≤ r ≤ n} f(l, r) after rearranging elements of b, taken modulo 998244353. Note that you should minimize the answer but not its remainder.

Examples

Input


5
1 8 7 2 4
9 7 2 9 3


Output


646


Input


1
1000000
1000000


Output


757402647


Input


2
1 3
4 2


Output


20
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<int, null_type, less<int>, rb_tree_tag, 
	tree_order_statistics_node_update>  nds;
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int>> 
#define vpci vector<pair<char,int>>
#define vpcc vector<pair<char,char>> 
#define mi map<int,int> 
#define mc map<char,int>
#define mpii map<pair<int,int>,int> 
#define mpci map<pair<char,int>,int>
#define mpsi map<pair<string,int>,int>
#define ms map<string,int>
#define pii pair<int,int>
#define pc pair<char,char>
#define fbo find_by_order // (use *) value at  index in sorted array.
#define odk order_of_key  // tells index of element in array.
#define int long long int
#define double long double
#define inf 1e18
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define debug(x) cout<<x<<endl
#define debugc cout<<"!"<<endl
#define wt() int tt; cin>>tt;while(tt--)
# define f(x,a,b) for(int x = a; x <= b; x++)
# define fr(x,a,b) for(int x = b; x >= a; x--)
int max(int a,int b){return (a>=b)?a:b;}
int min(int a,int b){return (a<=b)?a:b;}
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
int rnd(int limit) 
{ 
    random_device rd;  
    mt19937 gen(rd()); 
    uniform_int_distribution<> dis(1, limit); 
    return dis(gen); 
}
int modInverse(int a, int m) 
{ 
    int m0 = m; 
    int y = 0, x = 1; 
    if (m == 1) 
        return 0; 
    while (a > 1) { 
        int q = a / m; 
        int t = m; 
        m = a % m, a = t; 
        t = y; 
        y = x - q * y; 
        x = t; 
    } 
    if (x < 0) 
        x += m0; 
    return x; 
}
vpii p;
void factors(int n)  
{  
    int cnt=0;
    while (n % 2 == 0)  
    {  
        cnt++;
        n = n/2;  
    }  
    if(cnt)
    p.pb({2,cnt});
    cnt=0;
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        cnt=0;
        while (n % i == 0)  
        {  
            cnt++;  
            n = n/i;  
        }  
	if(cnt)
        p.pb({i,cnt});
    }  
    if (n > 2)  
    p.pb({n,1});
}

// In mathematics problem just always avoid floating precision errors(We can avoid it by multipling 
//everyting with the number we are dividing) and also avoid mod on negative number mistakes(always add +mod)

// __gcd(x,y) = __gcd(x - y,x)

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    vi a(n);
    vpii col;
    for(int i = 0; i < n; i++)
    cin>>a[i], col.pb({a[i], i});
    int v[n];
    for(int i = 0; i < n; i++)
    cin>>v[i];
    sort(v, v + n, greater<int>());
    sort(all(col));
    int sum1 = 0;
    vi ans1(n);
    for(int i = 0; i < n; i++)
    {
        int inx = col[i].ss;
        ans1[inx] = v[i];
    }
    int mod = 998244353;
    for(int i = 0; i < n; i++)
    {
        int c1 = ((i + 1) * (n - i)) % mod;
        int c2 = (a[i] * ans1[i]) % mod;
        int c3 = (c1 * c2) % mod;
        sum1 = (sum1 + c3) % mod;
    }
    cout<<sum1 % mod<<endl;
    /*
    vi ans(n);
    int l = 0;
    int r = n - 1;
    int sum = 0;
    for(int i = 0; i < n; i += 2)
    {
        if(i + 1 < n)
        {
            if(a[l] <= a[r])
            {
                ans[l] = v[i];
                ans[r] = v[i + 1];
            }
            else
            {
                ans[r] = v[i];
                ans[l] = v[i + 1];
            }
        }
        else
        ans[l] = v[i];
        l++;
        r--;
    }
    for(int i = 0; i < n; i++)
    {
        int c1 = ((i + 1) * (n - i)) % mod;
        int c2 = (a[i] * ans[i]) % mod;
        int c3 = (c1 * c2) % mod;
        sum = (sum + c3) % mod;
    }
    int final = min(sum)
    cout<<sum % mod<<endl;*/
}