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

public class Main {


    long MODULO = 998244353;

    void solve() throws IOException {
        int n = readInt();

        Long[] a = new Long[n];
        Long[] b = new Long[n];

        for (int i=0; i<n; ++i) a[i] = readLong();
        for (int i=0; i<n; ++i) b[i] = readLong();

        for (int i=0; i<n; ++i) {
            a[i] *= 1l * (i + 1)* (n - i);
        }

        Arrays.sort(b);
        Arrays.sort(a);

        long ans = 0;

        for (int i=0; i<n; ++i){
            ans += (a[i] % MODULO) * b[n - i - 1];
            ans %= MODULO;
        }

        out.println(ans);
    }



    class PersistentTree {
        ArrayList<Node> steps;
        int n;
        PersistentTree(int n) {
            this.n = n;
            steps = new ArrayList<>();
            Node root = build(1, n);
            steps.add(root);
        }

        Node build(int l, int r){
            if (l == r) {
                return new Node(0);
            }
            int mid = (l + r) / 2;
            Node left = build(l, mid);
            Node right = build(mid + 1, r);
            return new Node(left, right, 0);
        }

        void update(int target){
            Node prevRoot = steps.get(steps.size() - 1);
            Node newRoot = add(prevRoot, new Node(0), 1, n, target);
            steps.add(newRoot);
        }

        Node add(Node prevNode, Node curNode, int l, int r, int target){
            if (l == r) {
                return new Node(prevNode.sum + 1);
            }
            int mid = (l + r) / 2;
            if (target <= mid){
                curNode.right = prevNode.right;
                curNode.left = add(prevNode.left, new Node(0), l, mid, target);
            } else {
                curNode.left = prevNode.left;
                curNode.right = add(prevNode.right, new Node(0), mid + 1, r, target);
            }
            curNode.sum = curNode.right.sum + curNode.left.sum;
            return curNode;
        }

        int getAnswer(int step, int leftBorder, int rightBorder){
            Node root = steps.get(step);
          //  out.println(step + " " + leftBorder + " "+ rightBorder + " " + getAnswerForRoot(root, 1, n, leftBorder, rightBorder));
            return getAnswerForRoot(root, 1, n, leftBorder, rightBorder);
        }

        int getAnswerForRoot(Node root, int l, int r, int leftBorder, int rightBorder){
            if (leftBorder > rightBorder) return 0;
            if (l == leftBorder && r == rightBorder) return root.sum;
            int mid = (r + l) / 2;
            int leftSum = getAnswerForRoot(root.left, l, mid, leftBorder, Math.min(rightBorder, mid));
            int rightSum = getAnswerForRoot(root.right, mid + 1, r, Math.max(leftBorder, mid + 1), rightBorder);
            return leftSum + rightSum;
        }
    }


    class Node {
        Node left, right;
        int sum;
        Node(int sum){
            this.sum = sum;
        }
        Node (Node left, Node right, int sum){
            this.left = left;
            this.right = right;
            this.sum = sum;
        }
    }
    int[][] steps = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
    String fileName = "";
    int INF = Integer.MAX_VALUE / 2;
    private final static Random rnd = new Random();

    long binPow(long a, long b, long m) {
        if (b == 0) {
            return 1;
        }
        if (b % 2 == 1) {
            return ((a % m) * (binPow(a, b - 1, m) % m)) % m;
        } else {
            long c = binPow(a, b / 2, m);
            return (c * c) % m;
        }

    }
    boolean checkBit(long mask, int bit) {
        return (mask & (1l << bit)) > 0;
    }

    ////////////////////////////////////////////////////////////
    public static void main(String[] args) throws NumberFormatException, IOException {
        // TODO Auto-generated method stub
        new Main().run();
    }

    void run() throws NumberFormatException, IOException {
        solve();
        out.close();
    }

    ;

    BufferedReader in;
    PrintWriter out;

    StringTokenizer tok;
    String delim = " ";

    Main() throws FileNotFoundException {
        try {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        } catch (Exception e) {
            if (fileName.isEmpty()) {
                in = new BufferedReader(new InputStreamReader(System.in));
                out = new PrintWriter(System.out);
            } else {
                in = new BufferedReader(new FileReader(fileName + ".in"));
                out = new PrintWriter(fileName + ".out");
            }

        }
        tok = new StringTokenizer("");
    }

    String readLine() throws IOException {
        return in.readLine();
    }

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            String nextLine = readLine();
            if (null == nextLine) {
                return null;
            }

            tok = new StringTokenizer(nextLine);
        }
        return tok.nextToken(delim);
    }

    int readInt() throws NumberFormatException, IOException {
        return Integer.parseInt(readString());
    }

    long readLong() throws NumberFormatException, IOException {
        return Long.parseLong(readString());
    }

    int[] readIntArray(int n) throws NumberFormatException, IOException {
        int[] a = new int[n];
        for (int i = 0; i < n; ++i) {
            a[i] = readInt();
        }
        return a;
    }

    double readDouble() throws NumberFormatException, IOException {
        return Double.parseDouble(readString());
    }
}