#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18 + 7;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, -1};
const int N = 1e5 + 1;
struct Data {
  long long x, y;
  Data(long long x_, long long y_) {
    x = x_;
    y = y_;
  }
  Data() {}
};
long long Find_Intersection(Data A, Data B) {
  return (B.y - A.y) / (A.x - B.x);
}
long long n, C[N], pos[N], m;
Data a[N], I[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i].x;
  for (int i = 1; i <= n; i++) cin >> a[i].y;
  stack<Data> St;
  m = 1;
  I[1] = Data(-(long long)INF, (long long)INF);
  pos[m] = 1;
  St.push(Data(a[1].y, 0));
  long long cur = 1;
  for (int i = 2; i <= n; i++) {
    cur = min(cur, m);
    while (I[cur].y < a[i].x) cur++;
    C[i] = C[pos[cur]] + 1ll * a[i].x * a[pos[cur]].y;
    long long x = Find_Intersection(St.top(), Data(a[i].y, C[i]));
    while (x <= I[m].x) {
      St.pop();
      m--;
      x = Find_Intersection(St.top(), Data(a[i].y, C[i]));
    }
    St.push(Data(a[i].y, C[i]));
    I[m].y = x;
    I[++m] = Data(x, (long long)INF);
    pos[m] = i;
  }
  cout << C[n];
  return 0;
}
