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
import java.io.*;
import java.util.*;

public class tr0 {
	static PrintWriter out;
	static StringBuilder sb;
	static long mod =998244353;

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		out = new PrintWriter(System.out);
		int n=sc.nextInt();
		Long []a=new Long[n];
		Long []b=new Long[n];
		Long []k=new Long [n];
		for(int i=0;i<n;i++)
			a[i]=sc.nextLong();
		for(int i=0;i<n;i++)
			b[i]=sc.nextLong();
		long ans=0;
		for(int i=0;i<n;i++)
			k[i]=(long)(n-i)*(long)(i+1)*a[i];
		TreeMap<Long,Long> t=new TreeMap<>();
		for(int i=0;i<n;i++)
			t.put(k[i], t.getOrDefault(k[i], 0l)+1l);
		Arrays.sort(b);
		for(int i=0;i<n;i++) {
			ans=ans%mod+((b[i]%mod)*(t.lastKey()%mod))%mod;
			if(t.get(t.lastKey())==1)
				t.remove(t.lastKey());
			else
				t.put(t.lastKey(), t.get(t.lastKey())-1);
		}
		out.println(ans%mod);
		out.flush();
	}

	static public class segmentTree {
		int[] array, tree, lazy;
		int n;

		segmentTree(int[] aa) {
			array = aa;
			n = array.length - 1;
			tree = new int[n * 4];
			lazy = new int[n * 4];
			Arrays.fill(lazy, -1);
			build(1, 1, n);
		}

		public String toString() {
			return Arrays.toString(tree);
		}

		void build(int node, int l, int r) {
			if (l == r)
				tree[node] = array[r];
			else {
				int mid = (l + r) >> 1;
				build(node << 1, l, mid);
				build((node << 1) | 1, mid + 1, r);
				tree[node] = tree[node << 1] + tree[node << 1 | 1];
			}
		}

		void updateRange(int i, int j, int v) {
			updateR(1, 1, n, i, j, v);
		}

		void updateR(int node, int l, int r, int i, int j, int v) {
			if (i > r || j < l)
				return;
			if (i <= l && j >= r) {
				tree[node] = (r - l + 1) * v;
				lazy[node] = v;
			} else {
				int mid = l + r >> 1;
				propagate(node, l, mid, r);
				updateR(node << 1, l, mid, i, j, v);
				updateR(node << 1 | 1, mid + 1, r, i, j, v);
				tree[node] = tree[node << 1] + tree[node << 1 | 1];
			}
		}

		void propagate(int node, int b, int mid, int e) {
			if (lazy[node] != -1) {
				lazy[node << 1] = lazy[node];
				lazy[node << 1 | 1] = lazy[node];
				tree[node << 1] = (mid - b + 1) * lazy[node];
				tree[node << 1 | 1] = (e - mid) * lazy[node];
			}
			lazy[node] = -1;
		}

		int query(int i, int j) {
			return query(1, 1, n, i, j);
		}

		int query(int node, int b, int e, int i, int j) // O(log n)
		{
			if (i > e || j < b)
				return 0;
			if (b >= i && e <= j)
				return tree[node];
			int mid = b + e >> 1;
			propagate(node, b, mid, e);
			int q1 = query(node << 1, b, mid, i, j);
			int q2 = query(node << 1 | 1, mid + 1, e, i, j);
			return q1 + q2;

		}

	}

	static long fac(int n) {
		if (n == 0)
			return 1;
		if (n == 1)
			return 1;
		long ans = 1;
		for (int i = 1; i <= n; i++)
			ans = (i % mod * ans % mod) % mod;
		return ans % mod;
	}

	static long gcd(long a, long b) {

		if (b == 0)
			return a;
		return gcd(b, a % b);
	}

	static class pair implements Comparable<pair> {
		int num;
		int v;

		pair(int n, int v) {
			num = n;
			this.v = v;
		}

		public String toString() {
			return num + " " + v;
		}

		public int compareTo(pair o) {
			return o.v - v;
		}
	}

	static class unionfind {
		int[] p;
		int[] size;

		unionfind(int n) {
			p = new int[n];
			size = new int[n];

			for (int i = 0; i < n; i++) {
				p[i] = i;
			}
			Arrays.fill(size, 1);
		}

		int findSet(int v) {
			if (v == p[v])
				return v;
			return p[v] = findSet(p[v]);
		}

		boolean sameSet(int a, int b) {
			a = findSet(a);
			b = findSet(b);
			if (a == b)
				return true;
			return false;
		}

		int max() {
			int max = 0;
			for (int i = 0; i < size.length; i++)
				if (size[i] > max)
					max = size[i];
			return max;
		}

		void combine(int a, int b) {
			a = findSet(a);
			b = findSet(b);
			if (a == b)
				return;
			if (size[a] > size[b]) {
				p[b] = a;
				size[a] += size[b];

			} else {
				p[a] = b;
				size[b] += size[a];
			}
		}
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}