#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5;
long long a[MAXN], b[MAXN], f[MAXN], q[MAXN], p, Q, N;
int main() {
  cin >> N;
  for (int i = 1; i <= N; ++i) cin >> a[i];
  for (int i = 1; i <= N; ++i) cin >> b[i];
  for (int i = 1; i <= N; ++i) {
    while (p < Q - 1 &&
           (f[q[p + 1]] + b[q[p + 1]] * a[i]) < (f[q[p]] + b[q[p]] * a[i]))
      ++p;
    f[i] = (f[q[p]] + b[q[p]] * a[i]);
    while (Q > 1 &&
           ((f[q[Q - 2]] - f[i]) / (0. + b[i] - b[q[Q - 2]])) <
               ((f[q[Q - 2]] - f[q[Q - 1]]) / (0. + b[q[Q - 1]] - b[q[Q - 2]])))
      --Q;
    q[Q++] = i;
  }
  cout << f[N] << '\n';
}
