#include <bits/stdc++.h>
using namespace std;
struct tree {
  long long cost;
  long double x;
  long long b;
};
vector<tree> v;
long long bin_search(long long x, int l, int r) {
  int m = (l + r + 1) / 2;
  if (l == r) return v[l].cost + x * v[l].b;
  if (v[m].x > x)
    return bin_search(x, l, m - 1);
  else
    return bin_search(x, m, r);
}
void getx(long long cost, long long b) {
  long double x;
  x = (long double)(v[v.size() - 1].cost - cost) /
      (long double)(b - v[v.size() - 1].b);
  if (x > v[v.size() - 1].x) {
    tree tmp;
    tmp.b = b;
    tmp.cost = cost;
    tmp.x = x;
    v.push_back(tmp);
  } else {
    v.pop_back();
    getx(cost, b);
  }
}
int main() {
  int n;
  ios_base::sync_with_stdio(false);
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  tree tmp;
  tmp.cost = 0;
  tmp.x = 0;
  tmp.b = b[0];
  v.push_back(tmp);
  for (int i = 1; i < n; i++) {
    long long cost = bin_search(a[i], 0, v.size() - 1);
    getx(cost, b[i]);
    if (i == n - 1) cout << cost << endl;
  }
}
