#include <bits/stdc++.h>
using namespace std;
double get_inter(pair<long long, long long> p1, pair<long long, long long> p2) {
  double z = p1.first - p2.first;
  if (z == 0) {
    return (p1.second > p2.second ? 1e18 : -1e18);
  }
  return (p2.second - p1.second) / z;
}
int n;
long long a[1 << 20], b[1 << 20], dp[1 << 20];
pair<long long, long long> tp;
int s, t;
pair<long long, long long> v[1 << 20];
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];
  dp[1] = 0;
  s = t = 0;
  for (int i = 2; i <= n; i++) {
    tp.first = b[i - 1];
    tp.second = dp[i - 1];
    while (t > s + 1 &&
           get_inter(v[t - 1], v[t - 2]) >= get_inter(tp, v[t - 1]))
      --t;
    v[t] = tp;
    ++t;
    while (s + 1 < t && get_inter(v[s], v[s + 1]) < a[i]) ++s;
    tp = v[s];
    dp[i] = tp.first * a[i] + tp.second;
  }
  cout << dp[n] << endl;
  return 0;
}
