#include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
const long long INF = LONG_LONG_MAX;
int n, a[N + 1], b[N + 1];
long long f[N + 1];
pair<long long, long long> it[N * 4 + 1];
long long get(pair<long long, long long> line, int x) {
  return line.first * x + line.second;
}
void update(int k, int l, int r, pair<long long, long long> val) {
  long long lk = get(it[k], a[l]);
  long long rk = get(it[k], a[r]);
  long long lv = get(val, a[l]);
  long long rv = get(val, a[r]);
  if (lk <= lv && rk <= rv) return;
  if (lv <= lk && rv <= rk) {
    it[k] = val;
    return;
  }
  int mid = l + r >> 1;
  update(k << 1, l, mid, val);
  update(k * 2 + 1, mid + 1, r, val);
}
long long get(int k, int l, int r, int u) {
  if (l > u || r < u) return INF;
  long long res = get(it[k], a[u]);
  if (l == r) return res;
  int mid = l + r >> 1;
  res = min(res, get(k << 1, l, mid, u));
  res = min(res, get(k * 2 + 1, mid + 1, r, u));
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int i = 1; i <= n; ++i) cin >> b[i];
  fill(it + 1, it + n * 4 + 1, pair<long long, long long>(0, INF));
  f[1] = 0;
  update(1, 1, n, pair<long long, long long>(b[1], 0));
  for (int i = 2; i <= n; ++i) {
    f[i] = get(1, 1, n, i);
    update(1, 1, n, pair<long long, long long>(b[i], f[i]));
  }
  cout << f[n];
}
