6
12 8 12 17 20 5
17 4 8 8 8 4
 6
4 1 12 9 3 11
12 20 19 12 19 11
 1
1
1
 2
1 2
1 1
 1
7
5
 6
16 20 18 7 14 2
17 12 4 10 7 4

705
 917
 1
 9
 5
 741

import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * Created by timur on 28.03.15.
 */

public class TaskA {
    boolean eof;
    BufferedReader br;
    StringTokenizer st;
    PrintWriter out;

    public static void main(String[] args) throws IOException {
        new TaskA().run();
    }

    public String nextToken() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                eof = true;
                return "-1";
            }
        }
        return st.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() {
        return Long.parseLong(nextToken());
    }

    double nextDouble() {
        return Double.parseDouble(nextToken());
    }

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


    void run() throws IOException {
        InputStream input = System.in;
        PrintStream output = System.out;
        try {
            File f = new File("a.in");
            if (f.exists() && f.canRead()) {
                input = new FileInputStream(f);
                output = new PrintStream("a.out");
            }
        } catch (Throwable e) {
        }
        br = new BufferedReader(new InputStreamReader(input));
        out = new PrintWriter(output);
        solve();
        br.close();
        out.close();
    }


    static int[] getZFunction(String s) {
        int[] z = new int[s.length()];
        z[0] = 0;
        int l = 0;
        int r = 0;
        for (int i = 1; i < s.length(); i++) {
            z[i] = i >= r ? 0 : Math.min(z[i - l], r - i);
            while (z[i] + i < s.length()
                && s.charAt(z[i]) == s.charAt(i + z[i])) {
                z[i]++;
            }
            if (i + z[i] > r) {
                r = i + z[i];
                l = i;
            }
        }
        return z;
    }
    static int[] getPrefixFunction(String s) {
        int k = -1;
        int[] p = new int[s.length()];
        p[0] = -1;
        for (int i = 1; i < s.length(); i++) {
            while (k > -1 && s.charAt(i) != s.charAt(k + 1)) {
                k = p[k];
            }
            if (s.charAt(i) == s.charAt(k + 1)) {
                k++;
            }
            p[i] = k;
        }
        return p;
    }

    static int[] getZFunctionDumb(String s) {
        int[] z = new int[s.length()];
        z[0] = 0;
        for (int i = 1; i < s.length(); i++) {
            while (z[i] + i < s.length()
                && s.charAt(z[i]) == s.charAt(i + z[i])) {
                z[i]++;
            }
        }
        return z;
    }

    void solve() {
        int n = nextInt();
        long[] a = new long[n], b = new long[n], se = new long[n], st = new long[n], sb = new long[n];
        for (int i = 0; i< n; i++) {
            a[i] = nextLong();
        }
        for (int i = 0; i< n; i++) {
            b[i] = nextLong();
        }
        long cv = 0;

        se[n - 1] = a[n - 1] + b[ n - 1];
        for (int i = n - 2; i > -1; i--) {
            se[i] = a[i] + b[i] + se[i + 1];
        }


        st[n - 1] = b[n - 1];
        for (int i = n - 2; i > -1; i--) {
            long t = n - i;
            st[i] = st[i + 1] + se[i + 1] + b[i] * (t * 2 - 1);
        }

        sb[n - 1] = a[n - 1];
        for (int i = n - 2; i > -1; i--) {
            long t = n - i;
            sb[i] = sb[i + 1] + se[i + 1] + a[i] * (t * 2 - 1);
        }


        long maxAns = st[0];
        long ll = 0, ts = 0;
        for (int i = 1; i < n; i++) {
            ll += a[i - 1] * ts;
            ll += b[i - 1] * ts;
            if (i % 2 == 0) {
                ll += a[i - 1];
            } else {
                ll += b[i - 1];
            }
            ts += 2;
            if (i % 2 == 0) {
                //top
                maxAns = Math.max(maxAns, st[i] + ll + se[i] * ts);
            } else {
                //bot
                maxAns = Math.max(maxAns, sb[i] + ll + se[i] * ts);
            }

        }
        out.print(maxAns);
    }
}