#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 41;
const int mod = 1e9 + 7;
const long long INF = 1e18;
const int inf = 1e9;
long long a[N], b[N];
long long dp[N];
struct line {
  long long k, b;
  line() { k = b = 0; }
  line(long long k, long long b) : k(k), b(b) {}
  long long get(long long x) { return x * k + b; }
} st[N];
double inter(line i, line j) {
  return (double)(j.b - i.b) / (double)(i.k - j.k);
}
int sz;
const double eps = 1e-9;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  ;
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; ++i) {
    cin >> b[i];
  }
  int pos = 1;
  dp[1] = 0;
  st[++sz] = {b[1], dp[1]};
  for (int i = 2; i <= n; ++i) {
    while (pos < sz && inter(st[pos], st[pos + 1]) < a[i]) {
      ++pos;
    }
    dp[i] = st[pos].get(a[i]);
    line cur = {b[i], dp[i]};
    while (sz > pos && inter(cur, st[sz]) + eps < inter(st[sz], st[sz - 1])) {
      --sz;
    }
    st[++sz] = cur;
  }
  cout << dp[n];
}
