#include <bits/stdc++.h>
using namespace std;
deque<long long> m, b;
bool bad(int f1, int f2, int f3) {
  return 1.0 * (b[f3] - b[f1]) * (m[f1] - m[f2]) <=
         1.0 * (b[f2] - b[f1]) * (m[f1] - m[f3]);
}
void add(long long m_, long long b_) {
  m.push_back(m_);
  b.push_back(b_);
  int sz = m.size();
  while (sz >= 3 && bad(sz - 3, sz - 2, sz - 1)) {
    m.erase(m.end() - 2);
    b.erase(b.end() - 2);
    sz--;
  }
}
long long f(int i, long long x) { return m[i] * x + b[i]; }
const int mxn = 1e6 + 9;
long long n, ans = 0, a[mxn], cost[mxn];
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) cin >> cost[i];
  m.push_back(cost[1]);
  b.push_back(0);
  for (int i = 1; i <= n; i++) {
    while (m.size() >= 2 and f(0, a[i]) >= f(1, a[i])) {
      m.pop_front();
      b.pop_front();
    }
    long long tmp = f(0, a[i]);
    ans = tmp;
    add(cost[i], tmp);
  }
  cout << ans << endl;
  return 0;
}
