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.Scanner;

public class Codeforces {





    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        int m = in.nextInt();

        int[][] a = new int[3][333333];

        for (int i = 1; i <= 2; i++) {
            for (int j = 1; j <= m; j++) {
                a[i][j] = in.nextInt();
            }
        }


        int[] p1 = new int[333333], p2 = new int[333333], p3 = new int[333333], p4 = new int[333333],
                p5 = new int[333333], p6 = new int[333333], p7 = new int[333333], p8 = new int[333333];

        for (int j = 1; j <= m; j++) {
            p1[j] = p1[j-1] + (a[1][j] * (j-1));
            p2[j] = p2[j-1] + a[1][j];
            p3[j] = p3[j-1] + (a[2][j] * (j-1));
            p4[j] = p4[j-1] + a[2][j];
        }

        for (int j = m; j >= 1; j--) {
            p5[j] = p5[j+1] + (a[1][j] * (m - j));
            p6[j] = p6[j+1] + a[1][j];
            p7[j] = p7[j+1] + (a[2][j] * (m - j));
            p8[j] = p8[j+1] + a[2][j];
        }




        int cnt = 0, ans = 0, cur = 0;
        for (int j = 1; j <= m; j++) {
            if (j % 2 == 1) {

                cnt++;
                cur += a[1][j] * (cnt - 1);

                int db1 =  p1[m] - p1[j];
                db1 += (cnt-j) * (p2[m] - p2[j]);
                cur += db1;

                int cntt = m + j - 1;
                int db2 = p7[j];
                db2 += (cntt) * (p8[j]);
                cur += db2;

                ans = Math.max(ans, cur);
                cur -= db1 + db2;






                cnt++;
                cur += a[2][j] * (cnt-1);


                db1 = p3[m] - p3[j];
                db1 += (cnt-j) * (p4[m] - p4[j]);
                cur += db1;

                cntt = m + j;
                db2 = p5[j+1];
                db2 += (cntt) * (p6[j+1]);
                cur += db2;

                ans = Math.max(ans, cur);
                cur -= db1 + db2;

            } else {

                cnt++;
                cur += (cnt-1) * a[2][j];

                int db1 =  p3[m] - p3[j];
                db1 += (cnt - j) * (p4[m] - p4[j]);
                cur += db1;

                int cntt = m + j - 1;
                int db2 = p5[j];
                db2 += (cntt) * (p6[j]);
                cur += db2;

                ans = Math.max(ans, cur);
                cur -= db1 + db2;




                cnt++;
                cur += a[1][j] * (cnt-1);


                db1 = p1[m] - p1[j];
                db1 += (cnt - j) * (p2[m] - p2[j]);
                cur += db1;

                cntt = m + j;
                db2 = p7[j+1];
                db2 += (cntt) * (p8[j+1]);
                cur += db2;

                ans = Math.max(ans, cur);
                cur -= db1 + db2;

            }
        }


        System.out.println(ans);



    }


}
