#include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcd(T a, T b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
template <typename T>
T pow(T a, T b, long long m) {
  T ans = 1;
  while (b > 0) {
    if (b % 2 == 1) ans = ((ans % m) * (a % m)) % m;
    b /= 2;
    a = ((a % m) * (a % m)) % m;
  }
  return ans % m;
}
deque<long long> q;
long long a[300005], b[300005];
long long dp[300005];
double m(int x, int y) { return (dp[x] - dp[y]) / (double)(b[x] - b[y]); }
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) cin >> b[i];
  q.push_back(1);
  for (int i = 2; i <= n; i++) {
    while (q.size() >= 2 && m(q[0], q[1]) > -a[i]) q.pop_front();
    dp[i] = dp[q[0]] + a[i] * b[q[0]];
    while (q.size() >= 2 &&
           m(q[q.size() - 2], q[q.size() - 1]) < m(q[q.size() - 1], i))
      q.pop_back();
    q.push_back(i);
  }
  cout << dp[n];
}
