#include <bits/stdc++.h>
using namespace std;
map<long long, int> env;
int a[100010], b[100010], n;
long long cost[100010];
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  env[0] = cost[0] = 0;
  cost[1] = 1LL * b[0] * a[1];
  for (int i = 1; i < n - 1; i++) {
    map<long long, int>::iterator it;
    long long v;
    while (true) {
      it = env.end();
      --it;
      int p = it->second;
      v = ceil(1.0 / (b[i] - b[it->second]) * (cost[it->second] - cost[i]));
      if (v > it->first)
        break;
      else
        env.erase(it);
    }
    env[v] = i;
    int p = (--env.upper_bound(a[i + 1]))->second;
    cost[i + 1] = 1LL * b[p] * a[i + 1] + cost[p];
  }
  cout << cost[n - 1] << endl;
  return 0;
}
