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

705
 917
 1
 9
 5
 741

import java.util.Arrays;
import java.util.Scanner;

public class Contest {

  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);

    int n = Integer.valueOf(in.next());

    int[][] growth = new int[2][n];

    for (int i = 0; i < 2; i++) {
      for (int j = 0; j < n; j++) {
        growth[i][j] = Integer.valueOf(in.next());
      }
    }

    System.out.println(checkSolution(0, 0, growth, movings(false, n > 1, true), 0,  n, false, n == 1, ""));

//    int[][] growth = new int[][] {
//        {1, 2, 3},
//        {6, 5, 4}
//    };
//    int[][] growth = new int[][] {
//        {1, 1000, 10000},
//        {10, 100, 100000}
//    };
//    int[][] growth = new int[][] {
//        {7},
//        {5}
//    };
//    int[][] growth = new int[][] {
//        {12, 8, 12, 17, 20, 5},
//        {17, 4, 8 , 8 , 8 , 4}
//    };


//    int n = growth[0].length;
//
//    String trace = "(0, 0)";
//    long result = checkSolution(0, 0, growth, movings(false, n > 1, true), 0, n, false, n == 1, trace);
//    System.out.println(result);
  }

  private static long checkSolution(
      int row, int col,
      int[][] growth, boolean[] movings,
      int iteration,
      int n,
      boolean skipped,
      boolean visitedLastColumn,
      String trace
  ) {
//    System.out.println();
    String id = String.format("(i: %d, row: %d, col %d)", iteration, row, col);
//    System.out.println(String.format("Visiting %s", id));
//    System.out.println(String.format("Trace: %s", trace));
//    System.out.println(String.format("Growth: %d, score: %d", growth[row][col], growth[row][col] * iteration));
//    System.out.println(String.format("Allowed movings: %s", Arrays.toString(movings)));

    if (iteration == 2 * n - 1) {
      System.out.println(String.format("Finished iteration %d, returning %d, trace: %s", iteration, growth[row][col] * iteration, trace));
      return growth[row][col] * iteration;
    }

    long right = 0;
    long left = 0;
    long topOrBottom = 0;

    boolean movedRight = false;
    boolean movedLeft = false;
    boolean movedTopOdBottom = false;

    if (movings[Movings.RIGHT.value]) {
//      System.out.println("Moving right");
      String newTrace = trace + String.format(" -> (%d, %d)", row, col + 1);
      movedRight = true;
      boolean[] newMovings = movings(false, col + 2 < n, (!skipped && !movings[Movings.TOP_OR_BOTTOM.value]) || col + 1 == n - 1);
      right = checkSolution(row, col + 1, growth, newMovings, iteration + 1, n, skipped || movings[Movings.TOP_OR_BOTTOM.value], visitedLastColumn || col + 1 == n - 1, newTrace);
    }

    if (movings[Movings.LEFT.value] && visitedLastColumn) {
//      System.out.println("Moving left");
      String newTrace = trace + String.format(" -> (%d, %d)", row, col - 1);
      movedLeft = true;
      boolean[] newMovings = movings(col - 2 >= 0, false, false);
      left = checkSolution(row, col - 1, growth, newMovings, iteration + 1, n, skipped, visitedLastColumn, newTrace);
    }

    int nextRow = 1 - row;
    if (movings[Movings.TOP_OR_BOTTOM.value]) {
//      System.out.println(String.format("Moving to the row %d", nextRow));
      String newTrace = trace + String.format(" -> (%d, %d)", nextRow, col);
      movedTopOdBottom = true;
      boolean[] newMovings = movings(visitedLastColumn, movings[Movings.RIGHT.value], false);
      topOrBottom = checkSolution(nextRow, col, growth, newMovings, iteration + 1, n, skipped, visitedLastColumn, newTrace);
    }

    if (!movedRight && !movedLeft && !movedTopOdBottom && iteration != 2 * n - 1) {
//      System.out.println("Can't move, return -1");
      return -1;
    }

//    System.out.println(String.format("Left: %d, right: %d, topOfBottom: %d, id: %s, trace: %s", left, right, topOrBottom, id, trace));
    return growth[row][col] * iteration + Math.max(left, Math.max(right, topOrBottom));
  }

  enum Movings {
    LEFT(0),
    RIGHT(1),
    TOP_OR_BOTTOM(2);

    int value;

    Movings(int value) {
      this.value = value;
    }
  }

  private static boolean[] movings(boolean left, boolean right, boolean topOrBottom) {
    boolean[] movings = new boolean[3];
    movings[Movings.LEFT.value] = left;
    movings[Movings.RIGHT.value] = right;
    movings[Movings.TOP_OR_BOTTOM.value] = topOrBottom;

    return movings;
  }
}
