#include <bits/stdc++.h>
using namespace std;
const long long N = 100100, MX = (long long)1e9;
long long n, a[N], b[N], d[N];
struct Line {
  long long m, c, lx, rx;
  long long fx(long long x) { return m * x + c; }
} L[N];
int t;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) cin >> b[i];
  d[1] = 0;
  int p = 1, t = 1;
  L[1] = {b[1], d[1], 0, MX};
  for (int i = 2; i <= n; i++) {
    while (p + 1 <= t and L[p + 1].fx(a[i]) <= L[p].fx(a[i])) p++;
    d[i] = L[p].fx(a[i]);
    Line l = {b[i], d[i], 0, MX};
    if (l.fx(MX) > L[t].fx(MX)) continue;
    long long lq = 1, rq = t, mid;
    while (lq < rq) {
      mid = lq + rq >> 1;
      long long xi = L[mid].rx;
      if (L[mid].fx(xi) > l.fx(xi))
        rq = mid;
      else
        lq = mid + 1;
    }
    t = lq;
    lq = L[t].lx, rq = L[t].rx;
    while (lq < rq) {
      mid = lq + rq >> 1;
      if (L[t].fx(mid) > l.fx(mid))
        rq = mid;
      else
        lq = mid + 1;
    }
    l.lx = lq;
    if (lq - 1 >= L[t].lx)
      L[t].rx = lq - 1;
    else
      t--;
    L[++t] = l;
  }
  cout << d[n] << '\n';
  return 0;
}
