#include <bits/stdc++.h>
using namespace std;
int head, tail, n, q[100100];
long long f[100100], a[100100], b[100010];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%I64d", &a[i]);
  for (int i = 1; i <= n; i++) scanf("%I64d", &b[i]);
  f[1] = 0;
  head = tail = 1;
  q[head] = 1;
  for (int i = 2; i <= n; i++) {
    while (head < tail) {
      if ((1.0 * f[q[head]] + 1.0 * a[i] * b[q[head]]) >
          (1.0 * f[q[head + 1]] + 1.0 * a[i] * b[q[head + 1]]))
        head++;
      else
        break;
    }
    f[i] = f[q[head]] + b[q[head]] * a[i];
    while (head < tail) {
      if (1.0 * (f[q[tail]] - f[q[tail - 1]]) * (b[q[tail]] - b[i]) >
          1.0 * (f[i] - f[q[tail]]) * (b[q[tail - 1]] - b[q[tail]]))
        tail--;
      else
        break;
    }
    q[++tail] = i;
  }
  printf("%I64d", f[n]);
  return 0;
}
