#include <bits/stdc++.h>
long long f[1000000], a[1000000], b[1000000], q[1000000], n, l, r;
int main() {
  scanf("%I64d", &n);
  for (int i = 1; i <= n; i++) scanf("%I64d", &a[i]);
  for (int i = 1; i <= n; i++) scanf("%I64d", &b[i]);
  l = 0;
  r = 0;
  q[0] = 1;
  f[1] = 0;
  for (int i = 2; i <= n; i++) {
    while (l < r && double(f[q[l + 1]] - f[q[l]]) / (double)a[i] <=
                        double(b[q[l]] - b[q[l + 1]]))
      l++;
    f[i] = f[q[l]] + a[i] * b[q[l]];
    while (l < r &&
           double(f[i] - f[q[r]]) / double(b[q[r]] - b[i]) <=
               double(f[q[r]] - f[q[r - 1]]) / double(b[q[r - 1]] - b[q[r]]))
      r--;
    r++;
    q[r] = i;
  }
  printf("%I64d\n", f[n]);
  return 0;
}
