#include <bits/stdc++.h>
using namespace std;
long long int st[100005][2] = {0}, dp[100005] = {0}, len = 0, a[100005] = {0},
              b[100005] = {0};
long long int llersection(long long int a, long long int b, long long int c,
                          long long int d) {
  return (d - b) / (a - c);
}
long long int srch(long long int num) {
  long long int r = len - 1, l = 0;
  while (r - l > 1) {
    long long int mid = (l + r) / 2;
    if (st[mid][1] <= num)
      l = mid;
    else
      r = mid;
  }
  if (st[r][1] <= num)
    return r;
  else
    return l;
}
int main() {
  ios::sync_with_stdio(false);
  long long int n;
  cin >> n;
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (long long int i = 0; i < n; i++) {
    cin >> b[i];
  }
  st[0][0] = 0;
  st[0][1] = 0;
  len++;
  for (long long int i = 1; i < n; i++) {
    long long int idx = st[srch(a[i])][0];
    dp[i] = dp[idx] + a[i] * b[idx];
    while (len > 1) {
      long long int idx = st[len - 2][0];
      if (llersection(b[i], dp[i], b[idx], dp[idx]) >= st[len - 1][1]) break;
      len--;
    }
    idx = st[len - 1][0];
    long long int d = llersection(b[i], dp[i], b[idx], dp[idx]);
    st[len][0] = i;
    st[len][1] = d;
    len++;
  }
  cout << dp[n - 1];
  return 0;
}
