#include <bits/stdc++.h>
using namespace std;
struct Line {
  long long int m, c;
  Line(long long int im, long long int ic) {
    m = im;
    c = ic;
  }
  long long int get(long long int x) { return m * x + c; }
};
deque<Line> myQueue;
int sz = 0;
bool isBad(Line p, Line c, Line n) {
  double t1 = (double(p.c - c.c)) / (double(p.m - c.m));
  double t2 = (double(n.c - c.c)) / (double(n.m - c.m));
  return t1 < t2;
}
void add(Line temp) {
  while (sz >= 2 && isBad(myQueue[sz - 2], myQueue[sz - 1], temp)) {
    sz--;
    myQueue.pop_back();
  }
  sz++;
  myQueue.push_back(temp);
}
int ptr = 0;
long long int query(long long int x) {
  if (ptr >= sz) {
    ptr = sz - 1;
  }
  while (ptr < sz - 1 && myQueue[ptr].get(x) > myQueue[ptr + 1].get(x)) {
    ptr++;
  }
  return myQueue[ptr].get(x);
}
int main() {
  int n;
  std::ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  long long int a[n + 1], b[n + 1];
  long long int dp[n + 1];
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {
    cin >> b[i];
  }
  dp[1] = 0;
  add(Line(b[1], dp[1]));
  for (int i = 2; i <= n; i++) {
    dp[i] = query(a[i]);
    add(Line(b[i], dp[i]));
  }
  cout << dp[n] << endl;
}
