#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
int main(int argc, char* argv[]) {
  std::ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  int n;
  cin >> n;
  vector<ll> heights(n), speeds(n);
  for (int i = (0); i < (n); ++i) cin >> heights[i];
  for (int i = (0); i < (n); ++i) cin >> speeds[i];
  vector<array<ll, 3>> ch;
  ch.push_back({0, 0, speeds[0]});
  unsigned int p = 0;
  ll q;
  for (int i = (1); i < (n); ++i) {
    p = min((size_t)p, ch.size() - 1);
    while (p < ch.size() - 1 && ch[p + 1][0] <= heights[i]) p++;
    q = ch[p][1] + ch[p][2] * heights[i];
    ll m = speeds[i];
    while (ch.size() && ((long double)ch.back()[2]) * ch.back()[0] - q >=
                            ((long double)m) * ch.back()[0] - ch.back()[1])
      ch.pop_back();
    if (ch.size()) {
      ll mo = ch.back()[2], no = ch.back()[1];
      ll x = (q - no + mo - m - 1) / (mo - m);
      ch.push_back({x, q, m});
    } else
      ch.push_back({0, q, m});
  }
  cout << q << '\n';
  cout.flush();
  return 0;
}
