#include <bits/stdc++.h>
using namespace std;
int i, j, k, n, m, l;
long long a[100010], b[100010], f[100010], g[100010];
inline long long cal(int x) { return f[x] + b[x] * a[i]; }
inline double work(int y, int z) { return (f[z] - f[y]) / (0. + b[y] - b[z]); }
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%I64d", &a[i]);
  for (i = 1; i <= n; i++) scanf("%I64d", &b[i]);
  f[1] = 0;
  g[l = *g = 1] = 1;
  for (i = 2; i <= n; i++) {
    for (; l < *g && cal(g[l]) >= cal(g[l + 1]); l++)
      ;
    f[i] = cal(g[l]);
    for (; l <= *g && work(g[*g - 1], g[*g]) >= work(g[*g], i); (*g)--)
      ;
    g[++*g] = i;
  }
  printf("%I64d\n", f[n]);
  return 0;
}
