#include <bits/stdc++.h>
using namespace std;
int n, ind;
long long a[100000], b[100000], c[100000], mina;
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n; ++i) cin >> b[i];
  deque<pair<long long, int> > lines;
  lines.push_back(make_pair(0, 0));
  c[0] = 0;
  for (int i = 1; i < n; ++i) {
    while (lines.size() > 1 && lines[1].first <= a[i]) lines.pop_front();
    c[i] = c[lines[0].second] + b[lines[0].second] * a[i];
    while (!lines.empty()) {
      mina = lines.back().first;
      ind = lines.back().second;
      if (c[ind] + b[ind] * mina >= c[i] + b[i] * mina)
        lines.pop_back();
      else
        break;
    }
    mina = 0;
    if (!lines.empty())
      mina = min(1000000000ll, 1 + (c[i] - c[ind]) / (b[ind] - b[i]));
    lines.push_back(make_pair(mina, i));
  }
  cout << c[n - 1] << endl;
}
