#include <bits/stdc++.h>
using namespace std;
int pointer;
vector<long long> M;
vector<long long> B;
bool bad(int l1, int l2, int l3) {
  double x_12 = double(B[l2] - B[l1]) / double(M[l1] - M[l2]);
  double x_13 = double(B[l3] - B[l1]) / double(M[l1] - M[l3]);
  return x_13 < x_12;
}
void add(long long m, long long b) {
  M.push_back(m);
  B.push_back(b);
  while (M.size() >= 3 && bad(M.size() - 3, M.size() - 2, M.size() - 1)) {
    M.erase(M.end() - 2);
    B.erase(B.end() - 2);
  }
}
long long query(long long x) {
  if (pointer > M.size()) pointer = M.size() - 1;
  while (pointer < M.size() - 1 &&
         M[pointer + 1] * x + B[pointer + 1] < M[pointer] * x + B[pointer])
    pointer++;
  return M[pointer] * x + B[pointer];
}
int main() {
  long long int a[100123];
  long long int b[100123];
  int n;
  scanf(" %d", &n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  long long int cost = 0;
  add(b[0], 0);
  pointer = 0;
  for (int i = 0; i < n; i++) {
    cost = query(a[i]);
    if (i < n) add(b[i], cost);
  }
  cout << cost << endl;
  return 0;
}
