#include <bits/stdc++.h>
using namespace std;
int a[(1 << 20)], b[(1 << 20)];
long long f[(1 << 20)];
struct line {
  long double l, r;
  long long k, b;
  int index;
  line(long long k, long long b, int ind) {
    this->k = k;
    this->b = b;
    this->index = ind;
    l = -1E10;
    r = 1E10;
  }
};
long double line_inter(line ln1, line ln2) {
  long long k1, b1, k2, b2;
  k1 = ln1.k;
  b1 = ln1.b;
  k2 = ln2.k;
  b2 = ln2.b;
  assert(k1 - k2);
  return ((long double)(b2 - b1)) / ((long double)(k1 - k2));
}
int main() {
  int i, j, n;
  cin >> n;
  for (i = 0; i < n; ++i) cin >> a[i];
  for (i = 0; i < n; ++i) cin >> b[i];
  deque<line> d;
  d.push_back(line(b[0], 0, 0));
  int low, high, middle;
  for (i = 1; i < n; ++i) {
    int sz = (int)d.size();
    low = 0;
    high = sz;
    while (low + 1 < high) {
      middle = (low + high) / 2;
      if (d[middle].l <= a[i])
        low = middle;
      else
        high = middle;
    }
    j = d[low].index;
    f[i] = f[j] + (long long)a[i] * b[j];
    line ln = line(b[i], f[i], i);
    long double x1 = 0.0, x2 = 0.0;
    if (sz == 1) {
      x1 = line_inter(d[sz - 1], ln);
      ln.l = x1;
      d[sz - 1].r = x1;
    } else if (sz > 1) {
      do {
        x1 = line_inter(d[sz - 1], ln);
        x2 = line_inter(d[sz - 2], ln);
        if (x1 <= x2) {
          d.pop_back();
          --sz;
          ln.l = x2;
          d[sz - 1].r = x2;
        } else {
          ln.l = x1;
          d[sz - 1].r = x1;
        }
      } while (sz > 1 && x1 <= x2);
    }
    d.push_back(ln);
    ++sz;
  }
  cout << f[n - 1];
  return 0;
}
