#include <bits/stdc++.h>
using namespace std;
struct point {
  long long x, y;
} f[(int)1E5 + 10];
long long a[(int)1E5 + 10], b[(int)1E5 + 10], ans;
int n, open, closed;
inline bool vp(long long x1, long long y1, long long x2, long long y2) {
  return ((double)x1 / y1 - (double)x2 / y2) >= 0;
}
long long get() {
  long long tmp = 0;
  char c;
  while ((c = getchar()) < '0' || c > '9')
    ;
  while ('0' <= c && c <= '9') tmp = tmp * 10 + c - '0', c = getchar();
  return tmp;
}
int main() {
  int i;
  long long tmp;
  scanf("%d", &n);
  for (i = 1; i <= n; ++i) a[i] = get();
  for (i = 1; i <= n; ++i) b[i] = get();
  open = closed = 1;
  f[1].y = 0;
  f[1].x = b[1];
  ans = b[1] * a[n];
  for (i = 2; i < n; ++i) {
    while (closed > open &&
           f[open].y + a[i] * f[open].x >= f[open + 1].y + a[i] * f[open + 1].x)
      ++open;
    tmp = f[open].y + a[i] * f[open].x;
    if (tmp + b[i] * a[n] < ans) ans = tmp + b[i] * a[n];
    while (closed > open &&
           vp(f[closed].x - f[closed - 1].x, f[closed].y - f[closed - 1].y,
              b[i] - f[closed - 1].x, tmp - f[closed - 1].y))
      --closed;
    f[++closed].x = b[i];
    f[closed].y = tmp;
  }
  printf("%I64d", ans);
  return 0;
}
