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

/*
Keep solving problems.
*/

import java.util.*;
import java.io.*;

public class CFA {
    BufferedReader br;
    PrintWriter out;
    StringTokenizer st;
    boolean eof;
    private static final long MOD = 1000L * 1000L * 1000L + 7;
    private static final int[] dx = {0, -1, 0, 1};
    private static final int[] dy = {1, 0, -1, 0};
    private static final String yes = "Yes";
    private static final String no = "No";

    List<Long> first = new ArrayList<>();
    List<Long> second = new ArrayList<>();
    long[] arr;
    long[] rev;
    long[] arrSum;
    long[] revSum;
    long[] prefArrSum;
    long[] prefRevSum;
    long[] calcZero;
    long[] calcOne;
    void solve() throws IOException {
        int n = nextInt();
        for (int i = 0; i < n; i++) {
            first.add(nextLong());
        }
        for (int i = 0; i < n; i++) {
            second.add(nextLong());
        }

        Collections.reverse(second);
        first.addAll(second);
        arr = new long[2 * n];
        rev = new long[2 * n];
        for (int i = 0; i < 2 * n; i++) {
            arr[i] = first.get(i);
            rev[i] = first.get(2 * n - 1 - i);
        }

        arrSum = new long[1 + 2 * n];
        revSum = new long[1 + 2 * n];
        for (int i = 1; i <= 2 * n; i++) {
            arrSum[i] = arrSum[i - 1] + arr[i - 1];
            revSum[i] = revSum[i - 1] + rev[i - 1];
        }

        prefArrSum = new long[1 + 2 * n];
        prefRevSum = new long[1 + 2 * n];
        for (int i = 1; i <= 2 * n; i++) {
            prefArrSum[i] = prefArrSum[i - 1] + arr[i - 1] * (i - 1);
            prefRevSum[i] = prefRevSum[i - 1] + rev[i - 1] * (i - 1);
        }

        calcZero = new long[n];
        calcOne = new long[n];
        int start = 0;
        int end = 2 * n - 1;
        for (int i = 0; i < n; i++) {
            //[start, end]
            long tmp = prefArrSum[end + 1] - prefArrSum[start];
            tmp += i * (arrSum[end + 1] - arrSum[start]);

            calcZero[i] = tmp;

            tmp = prefRevSum[end + 1] - prefRevSum[start];
            tmp += i * (revSum[end + 1] - revSum[start]);
            calcOne[i] = tmp;
            start++;
            end--;
        }

        Collections.reverse(second);
        long res = 0;
        long pref = 0;
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            if (i % 2 == 0) {
                res = Math.max(res, pref + calcZero[i]);
                pref += cnt * first.get(i);
                cnt++;
                pref += cnt * second.get(i);
                cnt++;
            }
            else {
                res = Math.max(res, pref + calcOne[i]);
                pref += cnt * second.get(i);
                cnt++;
                pref += cnt * first.get(i);
                cnt++;
            }
        }

        outln(res);
    }

    void shuffle(int[] a) {
        int n = a.length;
        for(int i = 0; i < n; i++) {
            int r = i + (int) (Math.random() * (n - i));
            int tmp = a[i];
            a[i] = a[r];
            a[r] = tmp;
        }
    }

    long gcd(long a, long b) {
        while(a != 0 && b != 0) {
            long c = b;
            b = a % b;
            a = c;
        }
        return a + b;
    }

    private void outln(Object o) {
        out.println(o);
    }
    private void out(Object o) {
        out.print(o);
    }
    private void formatPrint(double val) {
        outln(String.format("%.9f%n", val));
    }
    public CFA() throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }
    public static void main(String[] args) throws IOException {
        new CFA();
    }

    public long[] nextLongArr(int n) throws IOException{
        long[] res = new long[n];
        for(int i = 0; i < n; i++)
            res[i] = nextLong();
        return res;
    }
    public int[] nextIntArr(int n) throws IOException {
        int[] res = new int[n];
        for(int i = 0; i < n; i++)
            res[i] = nextInt();
        return res;
    }
    public String nextToken() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                eof = true;
                return null;
            }
        }
        return st.nextToken();
    }
    public String nextString() {
        try {
            return br.readLine();
        } catch (IOException e) {
            eof = true;
            return null;
        }
    }
    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }
    public long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }
    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }
}