import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        int[] a;
        int[] b;
        int n;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            n = in.nextInt();
            a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            b = new int[n];
            for (int i = 0; i < n; i++) {
                b[i] = in.nextInt();
            }
            long ans = 0;
            for (int i = 1; i <= 2 * n; i++) {
                ans = Math.max(ans, calc(i));
            }
            out.println(ans);
        }

        long calc(int pos) {
            long res = 0;
            int cur = 0;
            for (int i = 0; i < n; i++) {
                if (i % 2 == 0) {
                    res += (2 * i) * (long) a[i];
                    cur++;
                    if (cur == pos) {
                        return res + sumUp(cur, i + 1, i);
                    }
                    res += (2 * i + 1) * (long) b[i];
                    cur++;
                    if (cur == pos) {
                        return res + sumDown(cur, i + 1, i + 1);
                    }
                } else {
                    res += (2 * i) * (long) b[i];
                    cur++;
                    if (cur == pos) {
                        return res + sumDown(cur, i + 1, i);
                    }
                    res += (2 * i + 1) * (long) a[i];
                    cur++;
                    if (cur == pos) {
                        return res + sumUp(cur, i + 1, i + 1);
                    }
                }
            }
            return res;
        }

        long sumUp(int ind, int from, int to) {
            long res = 0;
            for (int i = from; i < n; i++) {
                res += (long) a[i] * ind;
                ind++;
            }
            for (int i = n - 1; i >= to; i--) {
                res += (long) b[i] * ind;
                ind++;
            }
            return res;
        }

        long sumDown(int ind, int from, int to) {
            long res = 0;
            for (int i = from; i < n; i++) {
                res += (long) b[i] * ind;
                ind++;
            }
            for (int i = n - 1; i >= to; i--) {
                res += (long) a[i] * ind;
                ind++;
            }
            return res;
        }

    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer stt;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
        }

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                return null;
            }
        }

        public String next() {
            while (stt == null || !stt.hasMoreTokens()) {
                stt = new StringTokenizer(nextLine());
            }
            return stt.nextToken();
        }

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

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        int[] a;
        int[] b;
        int n;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            n = in.nextInt();
            a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            b = new int[n];
            for (int i = 0; i < n; i++) {
                b[i] = in.nextInt();
            }
            long ans = 0;
            for (int i = 0; i < n; i++) {
                ans = Math.max(ans, calc(i) + tail(i));
            }
            out.println(ans);
        }

        long calc(int pos) {
            long res = 0;
            for (int i = 0; i < pos; i++) {
                if (i % 2 == 0) {
                    res += (2 * i) * (long) a[i];
                    res += (2 * i + 1) * (long) b[i];
                } else {
                    res += (2 * i) * (long) b[i];
                    res += (2 * i + 1) * (long) a[i];
                }
            }
            return res;
        }

        long tail(int pos) {
            long res = 0;
            int cnt = 2 * pos;
            if (pos % 2 == 0) {
                for (int i = pos; i < n; i++) {
                    res += cnt * a[i];
                    cnt++;
                }
                for (int i = n - 1; i >= pos; i--) {
                    res += cnt * b[i];
                    cnt++;
                }
            } else {
                for (int i = pos; i < n; i++) {
                    res += cnt * b[i];
                    cnt++;
                }
                for (int i = n - 1; i >= pos; i--) {
                    res += cnt * a[i];
                    cnt++;
                }
            }
            return res;
        }

    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer stt;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
        }

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                return null;
            }
        }

        public String next() {
            while (stt == null || !stt.hasMoreTokens()) {
                stt = new StringTokenizer(nextLine());
            }
            return stt.nextToken();
        }

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

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        int[] a;
        int[] b;
        int n;
        long[] _upTail;
        long[] _downTail;
        long[] _calc;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            n = in.nextInt();
            a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            b = new int[n];
            for (int i = 0; i < n; i++) {
                b[i] = in.nextInt();
            }
            long ans = 0;
            for (int i = 0; i < n; i++) {
                ans = Math.max(ans, calc(i) + tail(i));
            }
            out.println(ans);
        }

        long calc(int pos) {
            if (_calc == null) {
                _calc = new long[n];
                long res = 0;
                for (int i = 0; i < n; i++) {
                    _calc[i] = res;
                    if (i % 2 == 0) {
                        res += (2 * i) * (long) a[i];
                        res += (2 * i + 1) * (long) b[i];
                    } else {
                        res += (2 * i) * (long) b[i];
                        res += (2 * i + 1) * (long) a[i];
                    }
                }
            }
            return _calc[pos];
        }

        long tail(int pos) {
            long res = 0;
            if (pos % 2 == 0) {
                res += upTail(pos);
            } else {
                res += downTail(pos);
            }
            return res;
        }

        long upTail(int pos) {
            if (_upTail == null) {
                _upTail = new long[n];
                long[] up = new long[n];
                long[] down = new long[n];
                long sum = a[n - 1];
                up[n - 1] = 2 * (n - 1) * (long) a[n - 1];
                for (int i = n - 2; i >= 0; i--) {
                    up[i] = up[i + 1] - sum + 2 * i * (long) a[i];
                    sum += a[i];
                }
                down[n - 1] = (2 * n - 1) * (long) b[n - 1];
                sum = b[n - 1];
                for (int i = n - 2; i >= 0; i--) {
                    down[i] = down[i + 1] - sum + (2 * n - 1) * (long) b[i];
                    sum += b[i];
                }
                for (int i = 0; i < n; i++) {
                    _upTail[i] = up[i] + down[i];
                }
            }
            return _upTail[pos];
        }

        long downTail(int pos) {
            if (_downTail == null) {
                _downTail = new long[n];
                long[] up = new long[n];
                long[] down = new long[n];
                long sum = b[n - 1];
                down[n - 1] = 2 * (n - 1) * (long) b[n - 1];
                for (int i = n - 2; i >= 0; i--) {
                    down[i] = down[i + 1] - sum + 2 * i * (long) b[i];
                    sum += b[i];
                }
                up[n - 1] = (2 * n - 1) * (long) a[n - 1];
                sum = a[n - 1];
                for (int i = n - 2; i >= 0; i--) {
                    up[i] = up[i + 1] - sum + (2 * n - 1) * (long) a[i];
                    sum += a[i];
                }
                for (int i = 0; i < n; i++) {
                    _downTail[i] = up[i] + down[i];
                }
            }
            return _downTail[pos];
        }

    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer stt;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
        }

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                return null;
            }
        }

        public String next() {
            while (stt == null || !stt.hasMoreTokens()) {
                stt = new StringTokenizer(nextLine());
            }
            return stt.nextToken();
        }

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

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        int[] a;
        int[] b;
        int n;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            n = in.nextInt();
            a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            b = new int[n];
            for (int i = 0; i < n; i++) {
                b[i] = in.nextInt();
            }
            long ans = 0;
            for (int i = 1; i <= 2 * n; i++) {
                ans = Math.max(ans, calc(i));
            }
            out.println(ans);
        }

        long calc(int pos) {
            long res = 0;
            int cur = 0;
            for (int i = 0; i < n; i++) {
                if (i % 2 == 0) {
                    res += (2 * i) * (long) a[i];
                    cur++;
                    if (cur == pos) {
                        return res + sumUp(cur);
                    }
                    res += (2 * i + 1) * (long) b[i];
                    cur++;
                    if (cur == pos) {
                        return res + sumDown(cur);
                    }
                } else {
                    res += (2 * i) * (long) b[i];
                    cur++;
                    if (cur == pos) {
                        return res + sumDown(cur);
                    }
                    res += (2 * i + 1) * (long) a[i];
                    cur++;
                    if (cur == pos) {
                        return res + sumUp(cur);
                    }
                }
            }
            return res;
        }

        long sumUp(int ind) {
            int from;
            int to;
            if (ind % 4 == 1) {
                from = (ind - 1) / 2 + 1;
                to = (ind - 1) / 2;
            } else {
                from = (ind - 1) / 2 + 1;
                to = (ind - 1) / 2 + 1;
            }
            long res = 0;
            for (int i = from; i < n; i++) {
                res += (long) a[i] * ind;
                ind++;
            }
            for (int i = n - 1; i >= to; i--) {
                res += (long) b[i] * ind;
                ind++;
            }
            return res;
        }

        long sumDown(int ind) {
            int from;
            int to;
            if (ind % 4 == 2) {
                from = (ind - 1) / 2 + 1;
                to = (ind - 1) / 2 + 1;
            } else {
                from = (ind - 1) / 2 + 1;
                to = (ind - 1) / 2;
            }
            long res = 0;
            for (int i = from; i < n; i++) {
                res += (long) b[i] * ind;
                ind++;
            }
            for (int i = n - 1; i >= to; i--) {
                res += (long) a[i] * ind;
                ind++;
            }
            return res;
        }

    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer stt;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
        }

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                return null;
            }
        }

        public String next() {
            while (stt == null || !stt.hasMoreTokens()) {
                stt = new StringTokenizer(nextLine());
            }
            return stt.nextToken();
        }

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

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        int[] a;
        int[] b;
        int n;
        long[] _upTail;
        long[] _downTail;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            n = in.nextInt();
            a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            b = new int[n];
            for (int i = 0; i < n; i++) {
                b[i] = in.nextInt();
            }
            long ans = 0;
            for (int i = 0; i < n; i++) {
                ans = Math.max(ans, calc(i) + tail(i));
            }
            out.println(ans);
        }

        long calc(int pos) {
            long res = 0;
            for (int i = 0; i < pos; i++) {
                if (i % 2 == 0) {
                    res += (2 * i) * (long) a[i];
                    res += (2 * i + 1) * (long) b[i];
                } else {
                    res += (2 * i) * (long) b[i];
                    res += (2 * i + 1) * (long) a[i];
                }
            }
            return res;
        }

        long tail(int pos) {
            long res = 0;
            if (pos % 2 == 0) {
                res += upTail(pos);
            } else {
                res += downTail(pos);
            }
            return res;
        }

        long upTail(int pos) {
            if (_upTail == null) {
                _upTail = new long[n];
                long[] up = new long[n];
                long[] down = new long[n];
                long sum = a[n - 1];
                up[n - 1] = 2 * (n - 1) * (long) a[n - 1];
                for (int i = n - 2; i >= 0; i--) {
                    up[i] = up[i + 1] - sum + 2 * i * (long) a[i];
                    sum += a[i];
                }
                down[n - 1] = (2 * n - 1) * (long) b[n - 1];
                sum = b[n - 1];
                for (int i = n - 2; i >= 0; i--) {
                    down[i] = down[i + 1] - sum + (2 * n - 1) * (long) b[i];
                    sum += b[i];
                }
                for (int i = 0; i < n; i++) {
                    _upTail[i] = up[i] + down[i];
                }
            }
            return _upTail[pos];
        }

        long downTail(int pos) {
            if (_downTail == null) {
                _downTail = new long[n];
                long[] up = new long[n];
                long[] down = new long[n];
                long sum = b[n - 1];
                down[n - 1] = 2 * (n - 1) * (long) b[n - 1];
                for (int i = n - 2; i >= 0; i--) {
                    down[i] = down[i + 1] - sum + 2 * i * (long) b[i];
                    sum += b[i];
                }
                up[n - 1] = (2 * n - 1) * (long) a[n - 1];
                sum = a[n - 1];
                for (int i = n - 2; i >= 0; i--) {
                    up[i] = up[i + 1] - sum + (2 * n - 1) * (long) a[i];
                    sum += a[i];
                }
                for (int i = 0; i < n; i++) {
                    _downTail[i] = up[i] + down[i];
                }
            }
            return _downTail[pos];
        }

    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer stt;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
        }

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                return null;
            }
        }

        public String next() {
            while (stt == null || !stt.hasMoreTokens()) {
                stt = new StringTokenizer(nextLine());
            }
            return stt.nextToken();
        }

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

    }
}


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], b[] = new int[n], cr = 0, cc = 0;
        for(int i=0; i<n; i++)
            a[i] = sc.nextInt();
        for(int i=0; i<n; i++)
            b[i] = sc.nextInt();

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

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

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

        for(int i=0; i<2*n; i++){
            if(cc == 1) {
                ans3 += (i * b[cr]);
                if(i%2 == 0)
                    cc = 0;
                else
                    cr++;
            }
            else{
                ans3 += (i*a[cr]);
                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);
        }
    }
}


import java.io.*;
import java.util.*;
import java.lang.*;
import java.awt.*;
import java.awt.geom.*;
import java.math.*;
import java.text.*;
public class   cf913
{
  BufferedReader in;
  StringTokenizer as;
  int nums[],nums2[];
  long pfx1[], pfx2[];
  long topleft[], topright[], bottomleft[], bottomright[];
  public static void main (String[] args)
  {
    new cf913  ();
  }

  public cf913  ()
  {
    try
    {
      in = new BufferedReader (new InputStreamReader (System.in));
      int a = nextInt();
      nums = new int [a];
      boolean debug = false;
      nums2 = new int [a];
      topleft = new long [a];
      topright = new long [a];
      bottomright = new long [a];
      pfx2 = new long [a];
      pfx1 = new long [a];
      bottomleft = new long [a];
      for(int x = 0;x<a;x++)
      {
        nums[x] = nextInt();
      }
      for(int  x = 0;x<a;x++)
      {
        nums2[x] = nextInt();
      }
      pfx1[0] = nums[0];
      pfx2[0] = nums2[0];
      topleft[0] = nums[0];
      bottomleft[0] = nums2[0];
      topright[a-1] = nums[a-1];
      bottomright[a-1] = nums2[a-1];
      for(int x = 1;x<a;x++)
      {
        pfx1[x] = pfx1[x-1] + nums[x];
        pfx2[x] = pfx2[x-1] + nums2[x];
      }
      for(int x = 1;x<a;x++)
      {
        topleft[x] = nums[x] *(x+1) + topleft[x-1];
        bottomleft[x] = nums2[x] *(x+1) + bottomleft[x-1];
      }
      for(int x = a-2;x>=0;x--)
      {
        topright[x] = nums[x] * (a-x) + topright[x+1];
        bottomright[x] = nums2[x] * (a-x) + bottomright[x+1];
      }
      long max = -12;
      long sofar = 0;
      for(int x = 0;x<a;x++)
      {
        long temp1 = sofar;
        int day = 2*x + 1;
        if(x % 2 == 0)
        {
          if(x!=0)
          {
            temp1 += (pfx1[a-1]-pfx1[x-1])* x;
          }
          if(x != 0)
            temp1 += (topleft[a-1] - topleft[x-1]);
          else
            temp1 += topleft[a-1];

          if(x!=0)
            temp1+= (pfx2[a-1] - pfx2[x-1]) * (a+x);
          else
            temp1 += pfx2[a-1] *(a+x);

          temp1 += bottomright[x];
          sofar += nums[x] * day + nums2[x] *(day+1);
          max = Math.max(temp1, max);
        }
        else if(x % 2 == 1)
        {
          temp1 += (pfx2[a-1] - pfx2[x-1]) * x;
          temp1 += (bottomleft[a-1] - bottomleft[x-1]);
          temp1 += (pfx1[a-1] - pfx1[x-1]) * (a+x);
          temp1 += topright[x];
          sofar += nums2[x] * day + nums[x] *  (day+1);
          max = Math.max(temp1, max);

        }
        //       if(debug)
        //       System.out.println(temp1 - pfx1[a-1] - pfx2[a-2]);
      }
      System.out.println(max- pfx1[a-1] - pfx2[a-1]);
      if (debug)
        for(int x = 0;x<a;x++)
      {
        System.out.print(bottomright[x] + " ");
      }
    }

    catch(IOException e)
    {

    }
  }

  String next () throws IOException
  {
    while (as == null || !as.hasMoreTokens ())
    {
      as = new StringTokenizer (in.readLine ().trim ());
    }

    return as.nextToken ();
  }

  long nextLong () throws IOException
  {
    return Long.parseLong (next ());
  }

  int nextInt () throws IOException
  {
    return Integer.parseInt (next ());
  }

  double nextDouble () throws IOException
  {
    return Double.parseDouble (next ());
  }

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


import java.io.*;
import java.util.*;
import java.lang.*;
import java.awt.*;
import java.awt.geom.*;
import java.math.*;
import java.text.*;
public class   cf913
{
  BufferedReader in;
  StringTokenizer as;
  long nums[],nums2[];
  long pfx1[], pfx2[];
  long topleft[], topright[], bottomleft[], bottomright[];
  public static void main (String[] args)
  {
    new cf913  ();
  }

  public cf913  ()
  {
    try
    {
      in = new BufferedReader (new InputStreamReader (System.in));
      int a = nextInt();
      nums = new long [a];
      boolean debug = false;
      nums2 = new long [a];
      topleft = new long [a];
      topright = new long [a];
      bottomright = new long [a];
      pfx2 = new long [a];
      pfx1 = new long [a];
      bottomleft = new long [a];
      for(int x = 0;x<a;x++)
      {
        nums[x] = nextlong();
      }
      for(int  x = 0;x<a;x++)
      {
        nums2[x] = nextlong();
      }
      pfx1[0] = nums[0];
      pfx2[0] = nums2[0];
      topleft[0] = nums[0];
      bottomleft[0] = nums2[0];
      topright[a-1] = nums[a-1];
      bottomright[a-1] = nums2[a-1];
      for(int x = 1;x<a;x++)
      {
        pfx1[x] = pfx1[x-1] + nums[x];
        pfx2[x] = pfx2[x-1] + nums2[x];
      }
      for(int x = 1;x<a;x++)
      {
        topleft[x] = nums[x] *(x+1) + topleft[x-1];
        bottomleft[x] = nums2[x] *(x+1) + bottomleft[x-1];
      }
      for(int x = a-2;x>=0;x--)
      {
        topright[x] = nums[x] * (a-x) + topright[x+1];
        bottomright[x] = nums2[x] * (a-x) + bottomright[x+1];
      }
      long max = -12;
      long sofar = 0;
      for(int x = 0;x<a;x++)
      {
        long temp1 = sofar;
        long day = 2*x + 1;
        if(x % 2 == 0)
        {
          if(x!=0)
          {
            temp1 += (pfx1[a-1]-pfx1[x-1])* x;
          }
          if(x != 0)
            temp1 += (topleft[a-1] - topleft[x-1]);
          else
            temp1 += topleft[a-1];

          if(x!=0)
            temp1+= (pfx2[a-1] - pfx2[x-1]) * (a+x);
          else
            temp1 += pfx2[a-1] *(a+x);

          temp1 += bottomright[x];
          sofar += nums[x] * day + nums2[x] *(day+1);
          max = Math.max(temp1, max);
        }
        else if(x % 2 == 1)
        {
          temp1 += (pfx2[a-1] - pfx2[x-1]) * x;
          temp1 += (bottomleft[a-1] - bottomleft[x-1]);
          temp1 += (pfx1[a-1] - pfx1[x-1]) * (a+x);
          temp1 += topright[x];
          sofar += nums2[x] * day + nums[x] *  (day+1);
          max = Math.max(temp1, max);

        }
        //       if(debug)
        //       System.out.println(temp1 - pfx1[a-1] - pfx2[a-2]);
      }
      System.out.println(max- pfx1[a-1] - pfx2[a-1]);
      if (debug)
        for(int x = 0;x<a;x++)
      {
        System.out.print(bottomright[x] + " ");
      }
    }

    catch(IOException e)
    {

    }
  }

  String next () throws IOException
  {
    while (as == null || !as.hasMoreTokens ())
    {
      as = new StringTokenizer (in.readLine ().trim ());
    }

    return as.nextToken ();
  }

  long nextlong () throws IOException
  {
    return Long.parseLong (next ());
  }

  int nextInt () throws IOException
  {
    return Integer.parseInt (next ());
  }

  double nextDouble () throws IOException
  {
    return Double.parseDouble (next ());
  }

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


import java.io.*;
import java.util.*;
import java.lang.*;
import java.awt.*;
import java.awt.geom.*;
import java.math.*;
import java.text.*;
public class   cf912
{
  BufferedReader in;
  StringTokenizer as;
  int nums[],nums2[];
  public static void main (String[] args)
  {
    new cf912  ();
  }

  public cf912  ()
  {
    try
    {
      in = new BufferedReader (new InputStreamReader (System.in));
      int a = nextInt();
      int b = nextInt();
      int q = nextInt();
      nums = new int [a];
      int z = 0;
      String c = nextLine();
      String d = nextLine();
      for(;;)
      {
        int temp = c.indexOf(d,z);
        if(temp == -1)
          break;
        nums[temp]++;
        z = temp +1;
      }
      for(int x1 = 0;x1<q;x1++)
      {
        int aa = nextInt();
        int bb = nextInt();
        aa--;
        bb--;
        int temp1 = 0;
        for(int x = aa;x<bb-b+2;x++)
          temp1 += nums[x];
        System.out.println(temp1);
      }

    }

    catch(Exception e)
    {

    }
  }

  String next () throws IOException
  {
    while (as == null || !as.hasMoreTokens ())
    {
      as = new StringTokenizer (in.readLine ().trim ());
    }

    return as.nextToken ();
  }

  long nextLong () throws IOException
  {
    return Long.parseLong (next ());
  }

  int nextInt () throws IOException
  {
    return Integer.parseInt (next ());
  }

  double nextDouble () throws IOException
  {
    return Double.parseDouble (next ());
  }

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


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

public class Main {
    private static class Solver {
        private void Solve() {
            int n = inp.nextInt();
            long[] a = new long[n + 1];
            long[] b = new long[n + 1];
            for (int i = 1; i <= n; ++i) {
                a[i] = inp.nextLong();
            }
            for (int i = 1; i <= n; ++i) {
                b[i] = inp.nextLong();
            }

            long[] s = new long[n + 1];
            for (int i = n; i >= 1; --i) {
                s[i] = (a[i] + b[i]);
                if (i < n) {
                    s[i] = s[i] + s[i + 1];
                }
            }

            long[] f = new long[n + 1];
            long[] g = new long[n + 1];
            f[n] = b[n];
            g[n] = a[n];
            for (int i = n - 1; i >= 1; --i) {
                int c = (n - i + 1) * 2 - 1;
                f[i] = f[i + 1] + s[i + 1] + b[i] * c;
                g[i] = g[i + 1] + s[i + 1] + a[i] * c;
            }

            long ans = 0;
            long sum = 0;
            long cnt = 0;
            ans = Math.max(ans, f[1]);
            for (int i = 1; i <= n; ++i) {
                if (i % 2 == 1) {
                    sum += a[i] * cnt++;
                    sum += b[i] * cnt++;
                    long val = sum + (i == n ? 0 : (g[i + 1] + s[i + 1] * cnt));
                    ans = Math.max(ans, val);
                } else {
                    sum += b[i] * cnt++;
                    sum += a[i] * cnt++;
                    long val = sum + (i == n ? 0 : (f[i + 1] + s[i + 1] * cnt));
                    ans = Math.max(ans, val);
                }
            }

            out.println(ans);
        }
        static InputReader inp;
        static PrintWriter out;
    }

    private static class InputReader {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        private InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        private String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        private int nextInt() {
            return Integer.parseInt(next());
        }
        private long nextLong() {
            return Long.parseLong(next());
        }
        private int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; ++i) {
                a[i] = nextInt();
            }
            return a;
        }
    }
    public static void main(String[] args) throws IOException {
        if (!"true".equals(System.getProperty("ONLINE_JUDGE"))) {
            System.setIn(new FileInputStream(new File("input.txt")));
        }
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Solver.inp = new InputReader(inputStream);
        Solver.out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.Solve();
        Solver.out.close();
    }
}


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

public class Main {
    private static class Solver {
        private void Solve() {
            int n = inp.nextInt();
            long[] a = new long[n + 1];
            long[] b = new long[n + 1];
            for (int i = 1; i <= n; ++i) {
                a[i] = inp.nextLong();
            }
            for (int i = 1; i <= n; ++i) {
                b[i] = inp.nextLong();
            }

            long[] s = new long[n + 1];
            for (int i = n; i >= 1; --i) {
                s[i] = (a[i] + b[i]);
                if (i < n) {
                    s[i] = s[i] + s[i + 1];
                }
            }

            long[] f = new long[n + 1];
            long[] g = new long[n + 1];
            f[n] = b[n];
            g[n] = a[n];
            for (int i = n - 1; i >= 1; --i) {
                int c = (n - i + 1) * 2 - 1;
                f[i] = f[i + 1] + s[i + 1] + b[i] * c;
                g[i] = g[i + 1] + s[i + 1] + a[i] * c;
            }

            long ans = 0;
            long sum = 0;
            long cnt = 0;
            ans = Math.max(ans, f[1]);
            for (int i = 1; i <= n; ++i) {
                if (i % 2 == 1) {
                    sum += a[i] * cnt++;
                    sum += b[i] * cnt++;
                    long val = sum + (i == n ? 0 : (g[i + 1] + s[i + 1]));
                    ans = Math.max(ans, val);
                } else {
                    sum += b[i] * cnt++;
                    sum += a[i] * cnt++;
                    long val = sum + (i == n ? 0 : (f[i + 1] + s[i + 1]));
                    ans = Math.max(ans, val);
                }
            }

            out.println(ans);
        }
        static InputReader inp;
        static PrintWriter out;
    }

    private static class InputReader {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        private InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        private String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        private int nextInt() {
            return Integer.parseInt(next());
        }
        private long nextLong() {
            return Long.parseLong(next());
        }
        private int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; ++i) {
                a[i] = nextInt();
            }
            return a;
        }
    }
    public static void main(String[] args) throws IOException {
        if (!"true".equals(System.getProperty("ONLINE_JUDGE"))) {
            System.setIn(new FileInputStream(new File("input.txt")));
        }
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Solver.inp = new InputReader(inputStream);
        Solver.out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.Solve();
        Solver.out.close();
    }
}


import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int len = sc.nextInt();
    int[][] glade = new int[2][len];
    for (int j = 0; j < 2; j++) {
      for (int i = 0; i < len; i++) {
        glade[j][i] = sc.nextInt();
      }
    }
    long ans = solve(glade, len);
    System.out.println(ans);
  }

  private static long solve(int[][] glade, int len) {

    long ans = 0;
    int[] suffixArray1 = new int[len];
    int[] suffixArray2 = new int[len];
    int[] prefixArray = new int[len];
    int[] suffixArray = new int[len];
    int start = 0;

    for (int i = 0; i < len; i++) {
      boolean flag = i % 2 == 0;
      int i1 = flag ? 0 : 1;
      int i2 = flag ? 1 : 0;
      prefixArray[i] =
          start * glade[i1][i] + (start + 1) * glade[i2][i] + (i == 0 ? 0 : prefixArray[i - 1]);
      start += 2;
    }
    for (int i = 0; i < len; i++) {
      suffixArray[i] = glade[0][i] + glade[1][i] + (i == 0 ? 0 : suffixArray[i - 1]);
    }

    int r1 = 0;
    int r2 = 2 * len - 1;
    for (int i = 0; i < len; i++) {
      suffixArray1[i] = r1 * glade[0][i] + r2 * glade[1][i] + (i == 0 ? 0 : suffixArray1[i - 1]);
      r1++;
      r2--;
    }
    r1 = 2;
    r2 = 2 * len - 1;
    suffixArray2[0] = glade[1][0];
    for (int i = 1; i < len; i++) {
      suffixArray2[i] = suffixArray2[i - 1] + r2 * glade[0][i] + r1 * glade[1][i];
      r1++;
      r2--;
    }
    for (int i = 0; i < len; i += 2) {
      int temp =
          (i == 0 ? 0 : prefixArray[i - 1])
              + (i == 0
                  ? suffixArray1[len - 1]
                  : (suffixArray1[len - 1] - suffixArray1[i - 1])
                      + (i * (suffixArray[len - 1] - suffixArray[i - 1])));
      ans = Math.max(ans, temp);
//      System.out.println(temp);
    }

    for (int i = 1; i < len; i += 2) {
      int temp =
          prefixArray[i - 1]
              + suffixArray2[len - 1]
              - suffixArray2[i - 1]
              + ((i - 1) * (suffixArray[len - 1] - suffixArray[i - 1]));
      ans = Math.max(ans, temp);
//      System.out.println(temp);
    }

    return ans;
  }
}


import java.util.Scanner;

public class VasyaAndMushroomsv2 {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int T = Integer.parseInt(sc.nextLine());
    String[] a = sc.nextLine().split(" ");
    String[] b = sc.nextLine().split(" ");

    int[] aa = new int[T];
    int[] bb = new int[T];

    for (int i = 0; i < T; i++) {
      aa[i] = Integer.parseInt(a[i]);
      bb[i] = Integer.parseInt(b[i]);
    }

    long ans = solve(aa, bb);

    System.out.println(ans);
  }

  private static long solve(int[] aa, int[] bb) {
    long ans = 0;

    int len = aa.length;

    int tempAns = 0;
    for (int i = 0; i < len; i++) {
      tempAns += i * aa[i] + bb[i] * ((2 * len) - 1 - i);
    }
    if (tempAns > ans) {
      ans = tempAns;
    }
    tempAns = bb[0];
    int n = 0;
    for (int i = 2; i <= len; i++) {
      tempAns += i * bb[i - 1] + aa[i - 1] * ((2 * len) - 1 - n);
      n++;
    }
    if (tempAns > ans) {
      ans = tempAns;
    }

    int k = 3;
    boolean flag2 = true;
    while (k < 2*len) {
      boolean flag1 = true;
      tempAns = 0;
      int colCount=0;
      for (int i = 0; i < k; i = i + 2) {
        if (flag1) {
          tempAns += i * aa[colCount] + (i + 1) * bb[colCount];
        } else {
          tempAns += i * bb[colCount] + (i + 1) * aa[colCount];
        }
        colCount++;
        flag1 = !flag1;
      }

      int j = colCount;
      int m = 0;
      k++;
      int multiplier=k;
      for (int l = j; l < len; l++) {
        if (flag2) {
          tempAns += multiplier * aa[l] + bb[l] * ((2 * len) - 1 - m);
        } else {
          tempAns += multiplier * bb[l] + aa[l] * ((2 * len) - 1 - m);
        }
        multiplier++;
        m++;
      }

      flag2 = !flag2;
      if (tempAns > ans) {
        ans = tempAns;
      }
      k++;
    }

    return ans;
  }
}


import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int len = sc.nextInt();
    int[][] glade = new int[2][len];
    for (int j = 0; j < 2; j++) {
      for (int i = 0; i < len; i++) {
        glade[j][i] = sc.nextInt();
      }
    }
    long ans = solve(glade, len);
    System.out.println(ans);
  }

  private static long solve(int[][] glade, int n) {

    int N = 300 * 1000 + 9;
    long[][] sum123 = new long[2][N];
    long[][] sum321 = new long[2][N];
    long[][] sum111 = new long[2][N];

    for (int i = 0; i < 2; ++i)
      for (int j = n - 1; j >= 0; --j) {
        sum123[i][j] = sum123[i][j + 1] + (j + 1) * glade[i][j];
        sum321[i][j] = sum321[i][j + 1] + (n - j) * glade[i][j];
        sum111[i][j] = sum111[i][j + 1] + glade[i][j];
      }

    long res = 0, sum = 0;
    for (int i = 0, j = 0; j < n; ++j, i ^= 1) {
      long nres = sum;
      nres += sum123[i][j] + j * sum111[i][j];
      nres += sum321[i ^ 1][j] + (j + n) * sum111[i ^ 1][j];
      res = Math.max(res, nres);

      sum += glade[i][j] * (j + j + 1);
      sum += glade[i ^ 1][j] * (j + j + 2);
    }

    for (int j = 0; j < n; ++j) res -= glade[0][j] + glade[1][j];
    return res;
  }
}


import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int len = sc.nextInt();
    int[][] glade = new int[2][len];
    for (int j = 0; j < 2; j++) {
      for (int i = 0; i < len; i++) {
        glade[j][i] = sc.nextInt();
      }
    }
    long ans = solve(glade, len);
    System.out.println(ans);
  }

  private static long solve(int[][] glade, int len) {

    long ans = 0;
    long[] suffixArray1 = new long[len];
    long[] suffixArray2 = new long[len];
    long[] prefixArray = new long[len];
    long[] suffixArray = new long[len];
    long start = 0;

    for (int i = 0; i < len; i++) {
      boolean flag = i % 2 == 0;
      long i1 = flag ? 0 : 1;
      long i2 = flag ? 1 : 0;
      prefixArray[i] =
          start * glade[i1][i] + (start + 1) * glade[i2][i] + (i == 0 ? 0 : prefixArray[i - 1]);
      start += 2;
    }
    for (int i = 0; i < len; i++) {
      suffixArray[i] = glade[0][i] + glade[1][i] + (i == 0 ? 0 : suffixArray[i - 1]);
    }

    long r1 = 0;
    long r2 = 2 * len - 1;
    for (int i = 0; i < len; i++) {
      suffixArray1[i] = r1 * glade[0][i] + r2 * glade[1][i] + (i == 0 ? 0 : suffixArray1[i - 1]);
      r1++;
      r2--;
    }
    r1 = 2;
    r2 = 2 * len - 1;
    suffixArray2[0] = glade[1][0];
    for (int i = 1; i < len; i++) {
      suffixArray2[i] = suffixArray2[i - 1] + r2 * glade[0][i] + r1 * glade[1][i];
      r1++;
      r2--;
    }
    for (int i = 0; i < len; i += 2) {
      long temp =
          (i == 0 ? 0 : prefixArray[i - 1])
              + (i == 0
                  ? suffixArray1[len - 1]
                  : (suffixArray1[len - 1] - suffixArray1[i - 1])
                      + (i * (suffixArray[len - 1] - suffixArray[i - 1])));
      ans = Math.max(ans, temp);
//      System.out.println("First "+temp);
    }

    for (int i = 1; i < len; i += 2) {
      long temp =
          prefixArray[i - 1]
              + suffixArray2[len - 1]
              - suffixArray2[i - 1]
              + ((i - 1) * (suffixArray[len - 1] - suffixArray[i - 1]));
      ans = Math.max(ans, temp);
//      System.out.println("Second "+temp);
    }

    return ans;
  }
}


import java.util.LinkedHashSet;
import java.util.Objects;
import java.util.Scanner;
import java.util.Set;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int len = sc.nextInt();
    int[][] glade = new int[2][len];
    for (int j = 0; j < 2; j++) {
      for (int i = 0; i < len; i++) {
        glade[j][i] = sc.nextInt();
      }
    }
    long ans = solve(glade, len * 2);
    System.out.println(ans);
  }

  static class Point {
    int x;
    int y;

    public Point(int i, int j) {
      this.x = i;
      this.y = j;
    }

    @Override
    public boolean equals(Object o) {
      if (this == o) return true;
      if (o == null || getClass() != o.getClass()) return false;
      Point point = (Point) o;
      return x == point.x && y == point.y;
    }

    @Override
    public int hashCode() {
      return Objects.hash(x, y);
    }
  }

  private static long solve(int[][] glade, int len) {
    Set<Point> visited = new LinkedHashSet<>();
    long ans = Integer.MIN_VALUE;
    for (int i = 0; i < 2; i++) {
      for (int j = 0; j < glade[0].length; j++) {
        if (!((i == 0 && j == 0) || (i == 1 && j == 1))) {
          Point point = new Point(i, j);
          visited.add(point);
          ans = Math.max(ans, recurAndCheck(glade, len - 1, visited, i, j));
//          System.out.println(ans);
          visited.remove(point);
        }
      }
    }
    return ans;
  }

  private static long recurAndCheck(int[][] glade, int len, Set<Point> visited, int row, int col) {
    if (row == 0 && col == 0) {
      if (len == 0) {
        return 0;
      } else {
        return -1;
      }
    } else if (len == 0) {
      return -1;
    } else {
      int[] x = {-1, 0, 1, 0};
      int[] y = {0, -1, 0, 1};
      long ans = Integer.MIN_VALUE;
      int curResult = len * glade[row][col];
      for (int i = 0; i < 4; i++) {
        Point p = new Point(row + x[i], col + y[i]);
        if (valid(p, glade[0].length) && !visited.contains(p)) {
          visited.add(p);
          long tailResult = recurAndCheck(glade, len - 1, visited, p.x, p.y);
          if (tailResult != -1) {
            ans = Math.max(ans, curResult + tailResult);
          }
          visited.remove(p);
        }
      }
      return ans;
    }
  }

  private static boolean valid(Point p, int len) {
    return p.x >= 0 && p.x <= 1 && p.y >= 0 && p.y < len;
  }
}


import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int len = sc.nextInt();
    int[][] glade = new int[2][len];
    for (int j = 0; j < 2; j++) {
      for (int i = 0; i < len; i++) {
        glade[j][i] = sc.nextInt();
      }
    }
    long ans = solve(glade, len);
    System.out.println(ans);
  }

  private static long solve(int[][] glade, int len) {

    int ans = 0;
    int[] suffixArray1 = new int[len];
    int[] suffixArray2 = new int[len];
    int[] prefixArray = new int[len];
    int[] suffixArray = new int[len];
    int start = 0;

    for (int i = 0; i < len; i++) {
      boolean flag = i % 2 == 0;
      int i1 = flag ? 0 : 1;
      int i2 = flag ? 1 : 0;
      prefixArray[i] =
          start * glade[i1][i] + (start + 1) * glade[i2][i] + (i == 0 ? 0 : prefixArray[i - 1]);
      start += 2;
    }
    for (int i = 0; i < len; i++) {
      suffixArray[i] = glade[0][i] + glade[1][i] + (i == 0 ? 0 : suffixArray[i - 1]);
    }

    int r1 = 0;
    int r2 = 2 * len - 1;
    for (int i = 0; i < len; i++) {
      suffixArray1[i] = r1 * glade[0][i] + r2 * glade[1][i] + (i == 0 ? 0 : suffixArray1[i - 1]);
      r1++;
      r2--;
    }
    r1 = 2;
    r2 = 2 * len - 1;
    suffixArray2[0] = glade[1][0];
    for (int i = 1; i < len; i++) {
      suffixArray2[i] = suffixArray2[i - 1] + r2 * glade[0][i] + r1 * glade[1][i];
      r1++;
      r2--;
    }
    for (int i = 0; i < len; i += 2) {
      int temp =
          (i == 0 ? 0 : prefixArray[i - 1])
              + (i == 0
                  ? suffixArray1[len - 1]
                  : (suffixArray1[len - 1] - suffixArray1[i - 1])
                      + (i * (suffixArray[len - 1] - suffixArray[i - 1])));
      ans = Math.max(ans, temp);
//      System.out.println(temp);
    }

    for (int i = 1; i < len; i += 2) {
      int temp =
          prefixArray[i - 1]
              + suffixArray2[len - 1]
              - suffixArray2[i - 1]
              + ((i - 1) * (suffixArray[len - 1] - suffixArray[i - 1]));
      ans = Math.max(ans, temp);
//      System.out.println(temp);
    }

    return ans;
  }
}


import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int len = sc.nextInt();
    int[][] glade = new int[2][len];
    for (int j = 0; j < 2; j++) {
      for (int i = 0; i < len; i++) {
        glade[j][i] = sc.nextInt();
      }
    }
    long ans = solve(glade, len);
    System.out.println(ans);
  }

  private static long solve(int[][] glade, int len) {

    long ans = 0;
    long[] suffixArray1 = new long[len];
    long[] suffixArray2 = new long[len];
    long[] prefixArray = new long[len];
    long[] suffixArray = new long[len];
    int start = 0;

    for (int i = 0; i < len; i++) {
      boolean flag = i % 2 == 0;
      int i1 = flag ? 0 : 1;
      int i2 = flag ? 1 : 0;
      prefixArray[i] =
          start * glade[i1][i] + (start + 1) * glade[i2][i] + (i == 0 ? 0 : prefixArray[i - 1]);
      start += 2;
    }
    for (int i = 0; i < len; i++) {
      suffixArray[i] = glade[0][i] + glade[1][i] + (i == 0 ? 0 : suffixArray[i - 1]);
    }

    int r1 = 0;
    int r2 = 2 * len - 1;
    for (int i = 0; i < len; i++) {
      suffixArray1[i] = r1 * glade[0][i] + r2 * glade[1][i] + (i == 0 ? 0 : suffixArray1[i - 1]);
      r1++;
      r2--;
    }
    r1 = 2;
    r2 = 2 * len - 1;
    suffixArray2[0] = glade[1][0];
    for (int i = 1; i < len; i++) {
      suffixArray2[i] = suffixArray2[i - 1] + r2 * glade[0][i] + r1 * glade[1][i];
      r1++;
      r2--;
    }
    for (int i = 0; i < len; i += 2) {
      long temp =
          (i == 0 ? 0 : prefixArray[i - 1])
              + (i == 0
                  ? suffixArray1[len - 1]
                  : (suffixArray1[len - 1] - suffixArray1[i - 1])
                      + (i * (suffixArray[len - 1] - suffixArray[i - 1])));
      ans = Math.max(ans, temp);
//      System.out.println(temp);
    }

    for (int i = 1; i < len; i += 2) {
      long temp =
          prefixArray[i - 1]
              + suffixArray2[len - 1]
              - suffixArray2[i - 1]
              + ((i - 1) * (suffixArray[len - 1] - suffixArray[i - 1]));
      ans = Math.max(ans, temp);
//      System.out.println(temp);
    }

    return ans;
  }
}


import java.util.LinkedHashSet;
import java.util.Objects;
import java.util.Scanner;
import java.util.Set;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int len = sc.nextInt();
    int[][] glade = new int[2][len];
    for (int j = 0; j < 2; j++) {
      for (int i = 0; i < len; i++) {
        glade[j][i] = sc.nextInt();
      }
    }
    long ans = solve(glade, len * 2);
    System.out.println(ans);
  }

  static class Point {
    int x;
    int y;

    public Point(int i, int j) {
      this.x = i;
      this.y = j;
    }

    @Override
    public boolean equals(Object o) {
      if (this == o) return true;
      if (o == null || getClass() != o.getClass()) return false;
      Point point = (Point) o;
      return x == point.x && y == point.y;
    }

    @Override
    public int hashCode() {
      return Objects.hash(x, y);
    }
  }

  private static long solve(int[][] glade, int len) {
    Set<Point> visited = new LinkedHashSet<>();
    long ans = Integer.MIN_VALUE;
    for (int i = 0; i < 2; i++) {
      for (int j = 0; j < glade[0].length; j++) {
        if (!((i == 0 && j == 0) || (i == 1 && j == 1))) {
          Point point = new Point(i, j);
          visited.add(point);
          ans = Math.max(ans, recurAndCheck(glade, len - 1, visited, i, j));
          System.out.println(ans);
          visited.remove(point);
        }
      }
    }
    return ans;
  }

  private static long recurAndCheck(int[][] glade, int len, Set<Point> visited, int row, int col) {
    if (row == 0 && col == 0) {
      if (len == 0) {
        return 0;
      } else {
        return -1;
      }
    } else if (len == 0) {
      return -1;
    } else {
      int[] x = {-1, 0, 1, 0};
      int[] y = {0, -1, 0, 1};
      long ans = Integer.MIN_VALUE;
      int curResult = len * glade[row][col];
      for (int i = 0; i < 4; i++) {
        Point p = new Point(row + x[i], col + y[i]);
        if (valid(p, glade[0].length) && !visited.contains(p)) {
          visited.add(p);
          long tailResult = recurAndCheck(glade, len - 1, visited, p.x, p.y);
          if (tailResult != -1) {
            ans = Math.max(ans, curResult + tailResult);
          }
          visited.remove(p);
        }
      }
      return ans;
    }
  }

  private static boolean valid(Point p, int len) {
    return p.x >= 0 && p.x <= 1 && p.y >= 0 && p.y < len;
  }
}


import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int len = sc.nextInt();
    int[][] glade = new int[2][len];
    for (int j = 0; j < 2; j++) {
      for (int i = 0; i < len; i++) {
        glade[j][i] = sc.nextInt();
      }
    }
    long ans = solve(glade, len);
    System.out.println(ans);
  }

  private static long solve(int[][] glade, int len) {

    long ans = 0;
    long[] suffixArray1 = new long[len];
    long[] suffixArray2 = new long[len];
    long[] prefixArray = new long[len];
    long[] suffixArray = new long[len];
    long start = 0;

    for (int i = 0; i < len; i++) {
      boolean flag = i % 2 == 0;
      int i1 = flag ? 0 : 1;
      int i2 = flag ? 1 : 0;
      prefixArray[i] =
          start * glade[i1][i] + (start + 1) * glade[i2][i] + (i == 0 ? 0 : prefixArray[i - 1]);
      start += 2;
    }
    for (int i = 0; i < len; i++) {
      suffixArray[i] = glade[0][i] + glade[1][i] + (i == 0 ? 0 : suffixArray[i - 1]);
    }

    long r1 = 0;
    long r2 = 2 * len - 1;
    for (int i = 0; i < len; i++) {
      suffixArray1[i] = r1 * glade[0][i] + r2 * glade[1][i] + (i == 0 ? 0 : suffixArray1[i - 1]);
      r1++;
      r2--;
    }
    r1 = 2;
    r2 = 2 * len - 1;
    suffixArray2[0] = glade[1][0];
    for (int i = 1; i < len; i++) {
      suffixArray2[i] = suffixArray2[i - 1] + r2 * glade[0][i] + r1 * glade[1][i];
      r1++;
      r2--;
    }
    for (int i = 0; i < len; i += 2) {
      long temp =
          (i == 0 ? 0 : prefixArray[i - 1])
              + (i == 0
                  ? suffixArray1[len - 1]
                  : (suffixArray1[len - 1] - suffixArray1[i - 1])
                      + (i * (suffixArray[len - 1] - suffixArray[i - 1])));
      ans = Math.max(ans, temp);
//      System.out.println("First "+temp);
    }

    for (int i = 1; i < len; i += 2) {
      long temp =
          prefixArray[i - 1]
              + suffixArray2[len - 1]
              - suffixArray2[i - 1]
              + ((i - 1) * (suffixArray[len - 1] - suffixArray[i - 1]));
      ans = Math.max(ans, temp);
//      System.out.println("Second "+temp);
    }

    return ans;
  }
}


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

public class Shashank
{
    public static void main(String []args) throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;

        int n = Integer.parseInt(br.readLine());
        int[][] ab = new int[2][n + 2];
        int[][] f = new int[2][n + 2];
        int[] s = new int[n + 2];
        int[][] dp = new int[2][n + 2];

        st = new StringTokenizer(br.readLine());
        for(int i = 1; i < n + 1; i++)
            ab[0][i] = Integer.parseInt(st.nextToken());

        st = new StringTokenizer(br.readLine());
        for(int i = 1; i < n + 1; i++)
            ab[1][i] = Integer.parseInt(st.nextToken());

        for(int i = n; i > 0; i--)
        {
            s[i] += s[i + 1] + ab[0][i] + ab[1][i];
            f[0][i] = f[0][i + 1] + s[i + 1] + ab[1][i] * (2 * (n - i) + 1);
            f[1][i] = f[1][i + 1] + s[i + 1] + ab[0][i] * (2 * (n - i) + 1);
        }

        for(int i = n; i > 0; i--)
        {
            dp[0][i] = Math.max(f[0][i], dp[1][i + 1] + 2 * s[i + 1] + ab[1][i]);
            dp[1][i] = Math.max(f[1][i], dp[0][i + 1] + 2 * s[i + 1] + ab[0][i]);
        }

        System.out.println(dp[0][1]);
    }
}


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

public class Shashank
{
    public static void main(String []args) throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;

        int n = Integer.parseInt(br.readLine());
        long[][] ab = new long[2][n + 2];
        long[][] f = new long[2][n + 2];
        long[] s = new long[n + 2];
        long[][] dp = new long[2][n + 2];

        st = new StringTokenizer(br.readLine());
        for(int i = 1; i < n + 1; i++)
            ab[0][i] = Long.parseLong(st.nextToken());

        st = new StringTokenizer(br.readLine());
        for(int i = 1; i < n + 1; i++)
            ab[1][i] = Long.parseLong(st.nextToken());

        for(int i = n; i > 0; i--)
        {
            s[i] += s[i + 1] + ab[0][i] + ab[1][i];
            f[0][i] = f[0][i + 1] + s[i + 1] + ab[1][i] * (2 * (n - i) + 1);
            f[1][i] = f[1][i + 1] + s[i + 1] + ab[0][i] * (2 * (n - i) + 1);
        }

        for(int i = n; i > 0; i--)
        {
            dp[0][i] = Math.max(f[0][i], dp[1][i + 1] + 2 * s[i + 1] + ab[1][i]);
            dp[1][i] = Math.max(f[1][i], dp[0][i + 1] + 2 * s[i + 1] + ab[0][i]);
        }

        System.out.println(dp[0][1]);
    }
}


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

public class Shashank
{
    public static void main(String []args) throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;

        int n = Integer.parseInt(br.readLine());
        long[][] ab = new long[2][n + 2];
        long[][] forward = new long[2][n + 2];
        long[] grow = new long[n + 2];
        long[][] dp = new long[2][n + 2];

        st = new StringTokenizer(br.readLine());
        for(int i = 1; i < n + 1; i++)
            ab[0][i] = Long.parseLong(st.nextToken());

        st = new StringTokenizer(br.readLine());
        for(int i = 1; i < n + 1; i++)
            ab[1][i] = Long.parseLong(st.nextToken());

        for(int i = n; i > 0; i--)
        {
            grow[i] += grow[i + 1] + ab[0][i] + ab[1][i];
            long mult = 2 * (n - i) + 1;
            forward[0][i] = forward[0][i + 1] + grow[i + 1] + ab[1][i] * mult;
            forward[1][i] = forward[1][i + 1] + grow[i + 1] + ab[0][i] * mult;
        }

        for(int i = n; i > 0; i--)
        {
            long add = 2 * grow[i + 1];
            dp[0][i] = Math.max(forward[0][i], dp[1][i + 1] + ab[1][i] + add);
            dp[1][i] = Math.max(forward[1][i], dp[0][i + 1] + ab[0][i] + add);
        }

        System.out.println(dp[0][1]);
    }
}


import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.Charset;
import java.util.Comparator;

public class ECF48A {
    public static void main(String[] args) throws Exception {
        boolean local = System.getProperty("ONLINE_JUDGE") == null;
        boolean async = false;

        Charset charset = Charset.forName("ascii");

        FastIO io = local ? new FastIO(new FileInputStream("E:\\DATABASE\\TESTCASE\\ECF48A.in"), System.out, charset) : new FastIO(System.in, System.out, charset);
        Task task = new Task(io);

        if (async) {
            Thread t = new Thread(null, task, "dalt", 1 << 27);
            t.setPriority(Thread.MAX_PRIORITY);
            t.start();
            t.join();
        } else {
            task.run();
        }

        io.flush();
    }

    public static class Task implements Runnable {
        final FastIO io;

        public Task(FastIO io) {
            this.io = io;
        }

        @Override
        public void run() {
            solve();
        }

        public void solve() {
            int n = io.readInt();
            int[][] rows = new int[2][n];
            for (int i = 0; i < 2; i++) {
                for (int j = 0; j < n; j++) {
                    rows[i][j] = io.readInt();
                }
            }

            long[][] counts = new long[2][n + 1];
            long sum = 0;
            for (int i = n - 1; i >= 0; i--) {
                counts[0][i] = counts[0][i + 1] - sum +
                        (long) (n * 2 - 1) * rows[0][i]
                        + (long) (2 * i) * rows[1][i];
                counts[1][i] = counts[1][i + 1] - sum +
                        (long) (n * 2 - 1) * rows[1][i]
                        + (long) (2 * i) * rows[0][i];
                sum += rows[1][i] + rows[0][i];
            }

            long max = 0;
            long total = 0;
            int row = 0;
            int col = 0;
            long time = 0;
            boolean changeLine = false;
            while (col < n) {
                int otherRow = (row + 1) % 2;

                if (!changeLine) {
                    max = Math.max(max, total + counts[otherRow][col]);
                }

                total += time * rows[row][col];
                max = Math.max(max, total);
                time++;

                if (col % 2 == 0) {
                    if (row == 0) {
                        row++;
                        changeLine = true;
                    } else {
                        col++;
                        changeLine = false;
                    }
                } else {
                    if (row == 1) {
                        row--;
                        changeLine = true;
                    } else {
                        col++;
                        changeLine = false;
                    }
                }
            }

            io.cache.append(max);
        }
    }

    public static class FastIO {
        private final InputStream is;
        private final OutputStream os;
        private final Charset charset;
        private StringBuilder defaultStringBuf = new StringBuilder(1 << 8);
        public final StringBuilder cache = new StringBuilder();

        private byte[] buf = new byte[1 << 13];
        private int bufLen;
        private int bufOffset;
        private int next;

        public FastIO(InputStream is, OutputStream os, Charset charset) {
            this.is = is;
            this.os = os;
            this.charset = charset;
        }

        private int read() {
            while (bufLen == bufOffset) {
                bufOffset = 0;
                try {
                    bufLen = is.read(buf);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
                if (bufLen == -1) {
                    return -1;
                }
            }
            return buf[bufOffset++];
        }

        public void skipBlank() {
            while (next >= 0 && next <= 32) {
                next = read();
            }
        }

        public int readInt() {
            int sign = 1;

            skipBlank();
            if (next == '+' || next == '-') {
                sign = next == '+' ? 1 : -1;
                next = read();
            }

            int val = 0;
            if (sign == 1) {
                while (next >= '0' && next <= '9') {
                    val = val * 10 + next - '0';
                    next = read();
                }
            } else {
                while (next >= '0' && next <= '9') {
                    val = val * 10 - next + '0';
                    next = read();
                }
            }

            return val;
        }

        public long readLong() {
            int sign = 1;

            skipBlank();
            if (next == '+' || next == '-') {
                sign = next == '+' ? 1 : -1;
                next = read();
            }

            long val = 0;
            if (sign == 1) {
                while (next >= '0' && next <= '9') {
                    val = val * 10 + next - '0';
                    next = read();
                }
            } else {
                while (next >= '0' && next <= '9') {
                    val = val * 10 - next + '0';
                    next = read();
                }
            }

            return val;
        }

        public double readDouble() {
            long num = readLong();
            if (next != '.') {
                return num;
            }

            next = read();
            long divisor = 1;
            long later = 0;
            while (next >= '0' && next <= '9') {
                divisor = divisor * 10;
                later = later * 10 + next - '0';
                next = read();
            }

            if (num >= 0) {
                return num + (later / (double) divisor);
            } else {
                return num - (later / (double) divisor);
            }
        }

        public String readString(StringBuilder builder) {
            skipBlank();

            while (next > 32) {
                builder.append((char) next);
                next = read();
            }

            return builder.toString();
        }

        public String readString() {
            defaultStringBuf.setLength(0);
            return readString(defaultStringBuf);
        }

        public int readString(char[] data, int offset) {
            skipBlank();

            int originalOffset = offset;
            while (next > 32) {
                data[offset++] = (char) next;
                next = read();
            }

            return offset - originalOffset;
        }

        public int readString(byte[] data, int offset) {
            skipBlank();

            int originalOffset = offset;
            while (next > 32) {
                data[offset++] = (byte) next;
                next = read();
            }

            return offset - originalOffset;
        }

        public void flush() {
            try {
                os.write(cache.toString().getBytes(charset));
                os.flush();
                cache.setLength(0);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        public boolean hasMore() {
            skipBlank();
            return next != -1;
        }
    }

    public static class Memory {
        public static <T> void swap(T[] data, int i, int j) {
            T tmp = data[i];
            data[i] = data[j];
            data[j] = tmp;
        }

        public static <T> int min(T[] data, int from, int to, Comparator<T> cmp) {
            int m = from;
            for (int i = from + 1; i < to; i++) {
                if (cmp.compare(data[m], data[i]) > 0) {
                    m = i;
                }
            }
            return m;
        }

        public static <T> void move(T[] data, int from, int to, int step) {
            int len = to - from;
            step = len - (step % len + len) % len;
            Object[] buf = new Object[len];
            for (int i = 0; i < len; i++) {
                buf[i] = data[(i + step) % len + from];
            }
            System.arraycopy(buf, 0, data, from, len);
        }
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Vadim Semenov
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static final class TaskC {
        public void solve(int __, InputReader in, PrintWriter out) {
            int length = in.nextInt();
            long[][] table = in.nextLongTable(2, length);
            long[][] mul = new long[2][length + 1];
            long[][] add = new long[2][length + 1];
            for (int i = 0; i < 2; ++i) {
                for (int j = length - 1; j >= 0; --j) {
                    mul[i][j] = mul[i][j + 1] + (j + 1) * table[i][j];
                    add[i][j] = add[i][j + 1] + table[i][j];
                }
            }
            long have = 0;
            long answer = 0;
            for (int i = 0; i < length; ++i) {
                for (int j = 0, currentRow = i % 2; j < 2; ++j, currentRow ^= 1) {
                    int nextRow = currentRow ^ 1;
                    int currentTime = i * 2 + j;
                    int nextTime = currentTime + (length - i);
                    long current = have +
                            (currentTime - i - 1) * add[currentRow][i] + mul[currentRow][i] +
                            (nextTime + length) * add[nextRow][i + 1] - mul[nextRow][i + 1];
                    if (j == 0) {
                        current += (2 * length - 1) * table[nextRow][i];
                    }
                    answer = Math.max(answer, current);
                    have += currentTime * table[currentRow][i];
                }
            }
            out.println(Math.max(answer, have));
        }

    }

    static class InputReader {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public long[][] nextLongTable(int rows, int columns) {
            long[][] table = new long[rows][columns];
            for (int i = 0; i < rows; i++) {
                for (int j = 0; j < columns; j++) {
                    table[i][j] = nextLong();
                }
            }
            return table;
        }

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

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

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(readLine());
            }
            return tokenizer.nextToken();
        }

        public String readLine() {
            String line;
            try {
                line = reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return line;
        }

    }
}


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

/**
 * @author baito
 */
@SuppressWarnings("unchecked")
public class Main
{
    static StringBuilder sb = new StringBuilder();
    static FastScanner sc = new FastScanner(System.in);
    static int INF = 1234567890;
    static long LINF = 123456789123456789L;
    static long MINF = -123456789123456789L;
    static long MOD = 1000000007;
    static int[] y4 = {0, 1, 0, -1};
    static int[] x4 = {1, 0, -1, 0};
    static int[] y8 = {0, 1, 0, -1, -1, 1, 1, -1};
    static int[] x8 = {1, 0, -1, 0, 1, -1, 1, -1};
    static long[] Fa;//factorial
    static boolean[] isPrime;
    static int[] primes;
    static char[][] map;

    static int N, M, K;
    static long[][] A;

    public static void main(String[] args)
    {
        //longを忘れるなオーバーフローするぞ
        N = sc.nextInt();
        A = sc.nextLongArray2(2, N);
        long maxRes = 0;
        long[] uruix = new long[2 * N];//a , 2b , 3c
        long[] druix = new long[2 * N];
        long[] urui = new long[2 * N];//a , 2b , 3c
        long[] drui = new long[2 * N];
        for (int i = 1; i < 2 * N; i++)
        {
            int h, w;
            if (i >= N)
            {
                h = 1;
                w = N - (i - (N - 1));
            }
            else
            {
                h = 0;
                w = i;
            }
            urui[i] = urui[i - 1] + A[h][w];
        }
        for (int i = 1; i < 2 * N; i++)
        {
            int h, w;
            if (i >= N)
            {
                h = 1;
                w = N - (i - (N - 1));
            }
            else
            {
                h = 0;
                w = i;
            }
            uruix[i] = uruix[i - 1] + A[h][w] * i;
        }
        for (int i = 1; i < 2 * N; i++)
        {
            int h, w;
            if (i <= N)
            {
                h = 1;
                w = i - 1;
            }
            else
            {
                h = 0;
                w = N - (i - N);
            }
            drui[i] = drui[i - 1] + A[h][w];
        }
        for (int i = 1; i < 2 * N; i++)
        {
            int h, w;
            if (i <= N)
            {
                h = 1;
                w = i - 1;
            }
            else
            {
                h = 0;
                w = N - (i - N);
            }
            druix[i] = druix[i - 1] + A[h][w] * i;
        }
        //どこでターンするか
        long sum = 0;
        for (int i = 0; i < N; i++)
        {
            long resu, resd;
            int usedd = (i + 1) / 2 * 2;
            int usedu = (i) / 2 * 2;
            int j = (i + 1) / 2 * 2;
            int k = (i) / 2 * 2;
            //上
            resu = sum + uruix[2 * N - 1 - usedd] + urui[2 * N - 1 - usedd] * j;
            resu -= (uruix[usedu] + urui[usedu] * j);

            resd = sum + druix[2 * N - 1 - usedu] + drui[2 * N - 1 - usedu] * k;
            resd -= (druix[usedd] + drui[usedd] * k);

            maxRes = Math.max(maxRes, resu);
            maxRes = Math.max(maxRes, resd);
            //上
            sum += A[1 - (i % 2)][i] * (i * 2 + 1);
            if (i < N - 1) sum += A[1 - (i % 2)][i + 1] * (i * 2 + 2);
        }
        System.out.println(maxRes);
    }

    public static long sqrt(long v)
    {
        long res = (long) Math.sqrt(v);
        while (res * res > v) res--;
        return res;
    }

    public static int upper0(int a)
    {
        if (a < 0) return 0;
        return a;
    }

    public static long upper0(long a)
    {
        if (a < 0) return 0;
        return a;
    }

    public static Integer[] toIntegerArray(int[] ar)
    {
        Integer[] res = new Integer[ar.length];
        for (int i = 0; i < ar.length; i++)
        {
            res[i] = ar[i];
        }
        return res;
    }

    //k個の次の組み合わせをビットで返す 大きさに上限はない 110110 -> 111001
    public static int nextCombSizeK(int comb, int k)
    {
        int x = comb & -comb; //最下位の1
        int y = comb + x; //連続した下の1を繰り上がらせる
        return ((comb & ~y) / x >> 1) | y;
    }

    public static int keta(long num)
    {
        int res = 0;
        while (num > 0)
        {
            num /= 10;
            res++;
        }
        return res;
    }

    public static long getHashKey(int a, int b)
    {
        return (long) a << 32 | b;
    }

    public static boolean isOutofIndex(int x, int y)
    {
        if (x < 0 || y < 0) return true;
        if (map[0].length <= x || map.length <= y) return true;
        return false;
    }

    public static void setPrimes()
    {
        int n = 100001;
        isPrime = new boolean[n];
        List<Integer> prs = new ArrayList<>();
        Arrays.fill(isPrime, true);
        isPrime[0] = isPrime[1] = false;
        for (int i = 2; i * i <= n; i++)
        {
            if (!isPrime[i]) continue;
            prs.add(i);
            for (int j = i * 2; j < n; j += i)
            {
                isPrime[j] = false;
            }
        }
        primes = new int[prs.size()];
        for (int i = 0; i < prs.size(); i++)
            primes[i] = prs.get(i);
    }

    public static void revSort(int[] a)
    {
        Arrays.sort(a);
        reverse(a);
    }

    public static void revSort(long[] a)
    {
        Arrays.sort(a);
        reverse(a);
    }

    public static int[][] copy(int[][] ar)
    {
        int[][] nr = new int[ar.length][ar[0].length];
        for (int i = 0; i < ar.length; i++)
            for (int j = 0; j < ar[0].length; j++)
                nr[i][j] = ar[i][j];
        return nr;
    }

    /**
     *
指定した値以上の先頭のインデクスを返す

     *
配列要素が０のときは、０が返る。

     *
     * @returnint ： 探索した値以上で、先頭になるインデクス
     * 値が無ければ、挿入できる最小のインデックス
     */
    public static int lowerBound(final int[] arr, final int value)
    {
        int low = 0;
        int high = arr.length;
        int mid;

        while (low < high)
        {
            mid = ((high - low) >>> 1) + low;    //(low + high) / 2 (オーバーフロー対策)
            if (arr[mid] < value)
            {
                low = mid + 1;
            }
            else
            {
                high = mid;
            }
        }
        return low;
    }

    /**
     *
指定した値より大きい先頭のインデクスを返す

     *
配列要素が０のときは、０が返る。

     *
     * @returnint ： 探索した値より上で、先頭になるインデクス
     * 値が無ければ、挿入できる最小のインデックス
     */
    public static int upperBound(final int[] arr, final int value)
    {
        int low = 0;
        int high = arr.length;
        int mid;
        while (low < high)
        {
            mid = ((high - low) >>> 1) + low;    //(low + high) / 2 (オーバーフロー対策)
            if (arr[mid] <= value)
            {
                low = mid + 1;
            }
            else
            {
                high = mid;
            }
        }
        return low;
    }

    /**
     *
指定した値以上の先頭のインデクスを返す

     *
配列要素が０のときは、０が返る。

     *
     * @returnint ： 探索した値以上で、先頭になるインデクス
     * 値がなければ挿入できる最小のインデックス
     */
    public static long lowerBound(final long[] arr, final long value)
    {
        int low = 0;
        int high = arr.length;
        int mid;
        while (low < high)
        {
            mid = ((high - low) >>> 1) + low;    //(low + high) / 2 (オーバーフロー対策)
            if (arr[mid] < value)
            {
                low = mid + 1;
            }
            else
            {
                high = mid;
            }
        }
        return low;
    }

    /**
     *
指定した値より大きい先頭のインデクスを返す

     *
配列要素が０のときは、０が返る。

     *
     * @returnint ： 探索した値より上で、先頭になるインデクス
     * 値がなければ挿入できる最小のインデックス
     */
    public static long upperBound(final long[] arr, final long value)
    {
        int low = 0;
        int high = arr.length;
        int mid;
        while (low < high)
        {
            mid = ((high - low) >>> 1) + low;    //(low + high) / 2 (オーバーフロー対策)
            if (arr[mid] <= value)
            {
                low = mid + 1;
            }
            else
            {
                high = mid;
            }
        }
        return low;
    }

    //次の順列に書き換える、最大値ならfalseを返す
    public static boolean nextPermutation(int A[])
    {
        int len = A.length;
        int pos = len - 2;
        for (; pos >= 0; pos--)
        {
            if (A[pos]  1)
        {
            int mid = (ok + ng) / 2;
            if (A[mid] > A[pos]) ok = mid;
            else ng = mid;

        }

        swap(A, pos, ok);
        reverse(A, pos + 1, len - 1);

        return true;
    }

    //次の順列に書き換える、最小値ならfalseを返す
    public static boolean prevPermutation(int A[])
    {
        int len = A.length;
        int pos = len - 2;
        for (; pos >= 0; pos--)
        {
            if (A[pos] > A[pos + 1]) break;
        }
        if (pos == -1) return false;

        //posより小さい最大の数を二分探索
        int ok = pos + 1;
        int ng = len;
        while (Math.abs(ng - ok) > 1)
        {
            int mid = (ok + ng) / 2;
            if (A[mid] < A[pos]) ok = mid;
            else ng = mid;

        }

        swap(A, pos, ok);
        reverse(A, pos + 1, len - 1);

        return true;
    }

    //↓nCrをmod計算するために必要。　***factorial(N)を呼ぶ必要がある***
    static long ncr(int n, int r)
    {
        if (n < r) return 0;
        else if (r == 0) return 1;

        factorial(n);
        return Fa[n] / (Fa[n - r] * Fa[r]);
    }

    static long ncr2(int a, int b)
    {
        if (b == 0) return 1;
        else if (a < b) return 0;
        long res = 1;
        for (int i = 0; i < b; i++)
        {
            res *= a - i;
            res /= i + 1;
        }
        return res;
    }

    static long ncrdp(int n, int r)
    {
        if (n < r) return 0;
        long[][] dp = new long[n + 1][r + 1];
        for (int ni = 0; ni < n + 1; ni++)
        {
            dp[ni][0] = dp[ni][ni] = 1;
            for (int ri = 1; ri < ni; ri++)
            {
                dp[ni][ri] = dp[ni - 1][ri - 1] + dp[ni - 1][ri];
            }
        }
        return dp[n][r];
    }

    static long modNcr(int n, int r)
    {
        if (n < r) return 0;
        long result = Fa[n];
        result = result * modInv(Fa[n - r]) % MOD;
        result = result * modInv(Fa[r]) % MOD;
        return result;
    }

    public static long modSum(long... lar)
    {
        long res = 0;
        for (long l : lar)
            res = (res + l % MOD) % MOD;
        if (res < 0) res += MOD;
        res %= MOD;
        return res;
    }

    public static long modDiff(long a, long b)
    {
        long res = a % MOD - b % MOD;
        if (res < 0) res += MOD;
        res %= MOD;
        return res;
    }

    public static long modMul(long... lar)
    {
        long res = 1;
        for (long l : lar)
            res = (res * l % MOD) % MOD;
        if (res < 0) res += MOD;
        res %= MOD;
        return res;
    }

    public static long modDiv(long a, long b)
    {
        long x = a % MOD;
        long y = b % MOD;
        long res = (x * modInv(y)) % MOD;
        return res;
    }

    static long modInv(long n)
    {
        return modPow(n, MOD - 2);
    }

    static void factorial(int n)
    {
        Fa = new long[n + 1];
        Fa[0] = Fa[1] = 1;

        for (int i = 2; i <= n; i++)
        {
            Fa[i] = (Fa[i - 1] * i) % MOD;
        }

    }

    static long modPow(long x, long n)
    {
        long res = 1L;
        while (n > 0)
        {
            if ((n & 1) == 1)
            {
                res = res * x % MOD;
            }
            x = x * x % MOD;
            n >>= 1;
        }
        return res;
    }

    //↑nCrをmod計算するために必要

    static int gcd(int n, int r)
    {
        return r == 0 ? n : gcd(r, n % r);
    }

    static long gcd(long n, long r)
    {
        return r == 0 ? n : gcd(r, n % r);
    }

    static <T> void swap(T[] x, int i, int j)
    {
        T t = x[i];
        x[i] = x[j];
        x[j] = t;
    }

    static void swap(int[] x, int i, int j)
    {
        int t = x[i];
        x[i] = x[j];
        x[j] = t;
    }

    public static void reverse(int[] x)
    {
        int l = 0;
        int r = x.length - 1;
        while (l < r)
        {
            int temp = x[l];
            x[l] = x[r];
            x[r] = temp;
            l++;
            r--;
        }
    }

    public static void reverse(long[] x)
    {
        int l = 0;
        int r = x.length - 1;
        while (l < r)
        {
            long temp = x[l];
            x[l] = x[r];
            x[r] = temp;
            l++;
            r--;
        }
    }

    public static void reverse(char[] x)
    {
        int l = 0;
        int r = x.length - 1;
        while (l < r)
        {
            char temp = x[l];
            x[l] = x[r];
            x[r] = temp;
            l++;
            r--;
        }
    }

    public static void reverse(int[] x, int s, int e)
    {
        int l = s;
        int r = e;
        while (l < r)
        {
            int temp = x[l];
            x[l] = x[r];
            x[r] = temp;
            l++;
            r--;
        }
    }

    static int length(int a)
    {
        int cou = 0;
        while (a != 0)
        {
            a /= 10;
            cou++;
        }
        return cou;
    }

    static int length(long a)
    {
        int cou = 0;
        while (a != 0)
        {
            a /= 10;
            cou++;
        }
        return cou;
    }

    static int cou(boolean[] a)
    {
        int res = 0;
        for (boolean b : a)
        {
            if (b) res++;
        }
        return res;
    }

    static int cou(String s, char c)
    {
        int res = 0;
        for (char ci : s.toCharArray())
        {
            if (ci == c) res++;
        }
        return res;
    }

    static int countC2(char[][] a, char c)
    {
        int co = 0;
        for (int i = 0; i < a.length; i++)
            for (int j = 0; j < a[0].length; j++)
                if (a[i][j] == c) co++;
        return co;
    }

    static int countI(int[] a, int key)
    {
        int co = 0;
        for (int i = 0; i < a.length; i++)
            if (a[i] == key) co++;
        return co;
    }

    static int countI(int[][] a, int key)
    {
        int co = 0;
        for (int i = 0; i < a.length; i++)
            for (int j = 0; j < a[0].length; j++)
                if (a[i][j] == key) co++;
        return co;
    }

    static void fill(int[][] a, int v)
    {
        for (int i = 0; i < a.length; i++)
            for (int j = 0; j < a[0].length; j++)
                a[i][j] = v;
    }

    static void fill(long[][] a, long v)
    {
        for (int i = 0; i < a.length; i++)
            for (int j = 0; j < a[0].length; j++)
                a[i][j] = v;
    }

    static void fill(int[][][] a, int v)
    {
        for (int i = 0; i < a.length; i++)
            for (int j = 0; j < a[0].length; j++)
                for (int k = 0; k < a[0][0].length; k++)
                    a[i][j][k] = v;
    }

    static int max(int... a)
    {
        int res = Integer.MIN_VALUE;
        for (int i : a)
        {
            res = Math.max(res, i);
        }
        return res;
    }

    static long min(long... a)
    {
        long res = Long.MAX_VALUE;
        for (long i : a)
        {
            res = Math.min(res, i);
        }
        return res;
    }

    static int max(int[][] ar)
    {
        int res = Integer.MIN_VALUE;
        for (int i[] : ar)
            res = Math.max(res, max(i));
        return res;
    }

    static int min(int... a)
    {
        int res = Integer.MAX_VALUE;
        for (int i : a)
        {
            res = Math.min(res, i);
        }
        return res;
    }

    static int min(int[][] ar)
    {
        int res = Integer.MAX_VALUE;
        for (int i[] : ar)
            res = Math.min(res, min(i));
        return res;
    }

    static int sum(int[] a)
    {
        int cou = 0;
        for (int i : a)
            cou += i;
        return cou;
    }

    static int abs(int a)
    {
        return Math.abs(a);
    }

    static class FastScanner
    {

        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public FastScanner(InputStream in)
        {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        public String next()
        {
            if (tokenizer == null || !tokenizer.hasMoreTokens())
            {
                try
                {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e)
                {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        /*public String nextChar(){
            return (char)next()[0];
        }*/
        public String nextLine()
        {
            if (tokenizer == null || !tokenizer.hasMoreTokens())
            {
                try
                {
                    return reader.readLine();
                } catch (IOException e)
                {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

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

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

        public double nextDouble()
        {
            return Double.parseDouble(next());
        }

        public int[] nextIntArray(int n)
        {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = nextInt();
            }
            return a;
        }

        public int[] nextIntArrayOneIndex(int n)
        {
            int[] a = new int[n + 1];
            for (int i = 1; i < n + 1; i++)
            {
                a[i] = nextInt();
            }
            return a;
        }

        public int[] nextIntArrayDec(int n)
        {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = nextInt() - 1;
            }
            return a;
        }

        public int[][] nextIntArray2(int h, int w)
        {
            int[][] a = new int[h][w];
            for (int hi = 0; hi < h; hi++)
            {
                for (int wi = 0; wi < w; wi++)
                {
                    a[hi][wi] = nextInt();
                }
            }
            return a;
        }

        public int[][] nextIntArray2Dec(int h, int w)
        {
            int[][] a = new int[h][w];
            for (int hi = 0; hi < h; hi++)
            {
                for (int wi = 0; wi < w; wi++)
                {
                    a[hi][wi] = nextInt() - 1;
                }
            }
            return a;
        }

        //複数の配列を受け取る
        public void nextIntArrays2ar(int[] a, int[] b)
        {
            for (int i = 0; i < a.length; i++)
            {
                a[i] = sc.nextInt();
                b[i] = sc.nextInt();
            }
        }

        public void nextIntArrays2arDec(int[] a, int[] b)
        {
            for (int i = 0; i < a.length; i++)
            {
                a[i] = sc.nextInt() - 1;
                b[i] = sc.nextInt() - 1;
            }
        }

        //複数の配列を受け取る
        public void nextIntArrays3ar(int[] a, int[] b, int[] c)
        {
            for (int i = 0; i < a.length; i++)
            {
                a[i] = sc.nextInt();
                b[i] = sc.nextInt();
                c[i] = sc.nextInt();
            }
        }

        //複数の配列を受け取る
        public void nextIntArrays3arDecLeft2(int[] a, int[] b, int[] c)
        {
            for (int i = 0; i < a.length; i++)
            {
                a[i] = sc.nextInt() - 1;
                b[i] = sc.nextInt() - 1;
                c[i] = sc.nextInt();
            }
        }

        public Integer[] nextIntegerArray(int n)
        {
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = nextInt();
            }
            return a;
        }

        public char[] nextCharArray(int n)
        {
            char[] a = next().toCharArray();

            return a;
        }

        public char[][] nextCharArray2(int h, int w)
        {
            char[][] a = new char[h][w];
            for (int i = 0; i < h; i++)
            {
                a[i] = next().toCharArray();
            }
            return a;
        }

        //スペースが入っている場合
        public char[][] nextCharArray2s(int h, int w)
        {
            char[][] a = new char[h][w];
            for (int i = 0; i < h; i++)
            {
                a[i] = nextLine().replace(" ", "").toCharArray();
            }
            return a;
        }

        public char[][] nextWrapCharArray2(int h, int w, char c)
        {
            char[][] a = new char[h + 2][w + 2];
            //char c = '*';
            int i;
            for (i = 0; i < w + 2; i++)
                a[0][i] = c;
            for (i = 1; i < h + 1; i++)
            {
                a[i] = (c + next() + c).toCharArray();
            }
            for (i = 0; i < w + 2; i++)
                a[h + 1][i] = c;
            return a;
        }

        //スペースが入ってる時用
        public char[][] nextWrapCharArray2s(int h, int w, char c)
        {
            char[][] a = new char[h + 2][w + 2];
            //char c = '*';
            int i;
            for (i = 0; i < w + 2; i++)
                a[0][i] = c;
            for (i = 1; i < h + 1; i++)
            {
                a[i] = (c + nextLine().replace(" ", "") + c).toCharArray();
            }
            for (i = 0; i < w + 2; i++)
                a[h + 1][i] = c;
            return a;
        }

        public long[] nextLongArray(int n)
        {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = nextLong();
            }
            return a;
        }

        public long[][] nextLongArray2(int h, int w)
        {
            long[][] a = new long[h][w];
            for (int hi = 0; hi < h; hi++)
            {
                for (int wi = 0; wi < w; wi++)
                {
                    a[hi][wi] = nextLong();
                }
            }
            return a;
        }
    }
}