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.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
public class r48p3{

    public static void main(String args[]) {
        InputReader sc = new InputReader(System.in);
        PrintWriter pw = new PrintWriter(System.out);

        int n = sc.nextInt(), a[][] = new int[n][2], cr = 0, cc = 0;

        long dp[][][] = new long[n][2][2], sum[] = new long[n];

        for(int i=0; i<n; i++)
            a[i][0] = sc.nextInt();
        for(int i=0; i<n; i++)
            a[i][1] = sc.nextInt();

        sum[n-1] = a[n-1][0]+a[n-1][1];
        for(int i=n-2; i>=0; i--)
            sum[i] = sum[i+1]+a[i][0]+a[i][1];
/*
        for(int i=0; i<n; i++)
            pw.print(sum[i]+" ");*/

        dp[n-1][0][0] = a[n-1][1];
        dp[n-1][0][1] = a[n-1][1];

        dp[n-1][1][0] = a[n-1][0];
        dp[n-1][1][1] = a[n-1][0];

        for(int i=n-2; i>=0; i--){
            dp[i][0][1] = dp[i+1][0][1]+sum[i+1]+(2*(n-i-1)+1)*a[i][1];
            dp[i][0][0] = Math.max(a[i][1]+2*sum[i+1]+Math.max(dp[i+1][1][1], dp[i+1][1][0]), dp[i][0][1]);

            dp[i][1][1] = dp[i+1][1][1]+sum[i+1]+(2*(n-i-1)+1)*a[i][0];
            dp[i][1][0] = Math.max(a[i][0]+2*sum[i+1]+Math.max(dp[i+1][0][1], dp[i+1][0][0]), dp[i][1][1]);
        }

        pw.println(dp[0][0][0]);

/*        long ans1 = 0, ans2 = 0, ans3 = 0;

        for(int i=1; i<=n; i++)
            ans1 += (i*a[i-1][1]);
        for(int i=n-1, j = n+1; i>1; i--, j++)
            ans1 += (j*a[i][0]);

        for(int i=1; i<n; i++)
            ans2 += (i*a[i][0]);
        for(int i=n-1, j=n; i>=0; i--, j++)
            ans2 += (j*a[i][1]);

        for(int i=0; i<2*n; i++){
            ans3 += (i*a[cr][cc]);
            if(cc == 1) {
                if(i%2 == 0)
                    cc = 0;
                else
                    cr++;
            }
            else{
                if(i%2 == 0)
                    cc = 1;
                else
                    cr++;
            }
        }

        long ans = Math.max(ans1, Math.max(ans2, ans3));
        pw.println(ans);*/
        pw.flush();
        pw.close();
    }

    static class InputReader {
        private final InputStream stream;
        private final byte[] buf = new byte[8192];
        private int curChar, snumChars;
        private SpaceCharFilter filter;

        InputReader(InputStream stream) {
            this.stream = stream;
        }

        int snext() {
            if (snumChars == -1)
                throw new InputMismatchException();
            if (curChar >= snumChars) {
                curChar = 0;
                try {
                    snumChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (snumChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        int nextInt() {
            int c = snext();
            while (isSpaceChar(c)) {
                c = snext();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = snext();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = snext();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        long nextLong() {
            int c = snext();
            while (isSpaceChar(c)) {
                c = snext();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = snext();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = snext();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        String readString() {
            int c = snext();
            while (isSpaceChar(c)) {
                c = snext();
            }
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = snext();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        String nextLine() {
            int c = snext();
            while (isSpaceChar(c))
                c = snext();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = snext();
            } while (!isEndOfLine(c));
            return res.toString();
        }

        boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private boolean isEndOfLine(int c) {
            return c == '\n' || c == '\r' || c == -1;
        }

        public interface SpaceCharFilter {
            boolean isSpaceChar(int ch);
        }
    }
}