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