#include <bits/stdc++.h>
using namespace std;
const long long nax = 1e6 + 5;
struct line {
  long long m, c;
  long long val(long long x) { return m * x + c; }
  long double getm(line l) { return (long double)(c - l.c) / (l.m - m); }
};
long long n;
long long a[nax], b[nax], dp[nax];
deque<line> dq;
long long query(long long x) {
  long long l = 0, r = dq.size() - 1;
  while (l < r) {
    long long mid = (l + r) / 2;
    if (dq[mid].getm(dq[mid + 1]) <= x) {
      r = mid;
    } else {
      l = mid + 1;
    }
  }
  return dq[l].val(x);
}
int main() {
  ios_base::sync_with_stdio(false);
  cout.tie(NULL);
  cin.tie(NULL);
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (long long i = 1; i <= n; i++) {
    cin >> b[i];
  }
  dp[1] = 0;
  dq.push_back({b[1], 0});
  for (long long i = 2; i <= n; i++) {
    dp[i] = query(a[i]);
    line cur = {b[i], dp[i]};
    while ((long long)dq.size() >= 2 && cur.getm(dq[0]) <= dq[0].getm(dq[1])) {
      dq.pop_front();
    }
    dq.push_front(cur);
  }
  cout << dp[n] << '\n';
}
