#include <bits/stdc++.h>
using namespace std;
long long a[100100], b[100100], f[100100];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%I64d", a + i);
  for (int i = 0; i < n; i++) scanf("%I64d", b + i);
  f[0] = 0;
  deque<int> q;
  q.push_back(0);
  for (int i = 1, m; i < n; i++) {
    while (q.size() > 1 && f[q[1]] - f[q[0]] <= a[i] * (b[q[0]] - b[q[1]]))
      q.pop_front();
    f[i] = f[q[0]] + b[q[0]] * a[i];
    while ((m = q.size()) > 1 &&
           1.0 * (f[q[m - 1]] - f[q[m - 2]]) / (f[i] - f[q[m - 1]]) >
               1.0 * (b[q[m - 2]] - b[q[m - 1]]) / (b[q[m - 1]] - b[i]))
      q.pop_back();
    q.push_back(i);
  }
  printf("%I64d\n", f[n - 1]);
  return 0;
}
