#include <bits/stdc++.h>
using namespace std;
const int MAX = 100000 + 10;
int n;
long long a[MAX];
long long b[MAX];
long long sum[MAX];
long long f[MAX];
long long qa[MAX], qb[MAX], head, top;
int main() {
  int i;
  scanf("%d", &n);
  for ((i) = (1); (i) <= (n); ++(i)) {
    cin >> a[i];
    sum[i] = sum[i - 1] + a[i];
  }
  for ((i) = (1); (i) <= (n); ++(i)) cin >> b[i];
  memset(f, -1, sizeof f);
  f[1] = 0;
  qa[++top] = b[1];
  qb[top] = 0;
  head = 1;
  for ((i) = (2); (i) <= (n); ++(i)) {
    long long first = a[i];
    while (head + 1 <= top &&
           qa[head] * first + qb[head] > qa[head + 1] * first + qb[head + 1])
      ++head;
    f[i] = min(qa[head] * first + qb[head], a[n] * b[1]);
    while (top >= head + 1 &&
           double(qa[top] - qa[top - 1]) / (qb[top] - qb[top - 1]) >
               double(b[i] - qa[top]) / (f[i] - qb[top]))
      --top;
    qa[++top] = b[i];
    qb[top] = f[i];
  }
  cout << f[n] << endl;
  return 0;
}
