#include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcd(T a, T b) {
  return b == 0 ? a : gcd(b, a % b);
}
template <typename T>
T LCM(T a, T b) {
  return a * (b / gcd(a, b));
}
template <typename T>
T expo(T b, T e, const T &m) {
  if (e <= 1) return e == 0 ? 1 : b;
  return (e & 1) == 0 ? expo((b * b) % m, e >> 1, m)
                      : (b * expo((b * b) % m, e >> 1, m)) % m;
}
template <typename T>
T modinv(T a) {
  return expo(a, 1000000007ll - 2, 1000000007ll);
}
long long dp[100003] = {0}, h[100003] = {0}, c[100003] = {0};
long long n;
int q[100003] = {0};
long long calc(int k, int j) { return dp[k] + c[k] * h[j]; }
double get_x(int i, int j) {
  return double(dp[i] - dp[j]) / double(c[j] - c[i]);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (__typeof(n) i = 1; i <= n; i++) {
    cin >> h[i];
  }
  for (__typeof(n) i = 1; i <= n; i++) {
    cin >> c[i];
  }
  int l = 1, r = 1;
  dp[0] = 0;
  for (__typeof(n) i = 1; i <= n; i++) {
    dp[i] = (1ll < 28) * (1ll < 28);
  }
  q[1] = 1;
  dp[1] = 0;
  for (__typeof(n) i = 2; i <= n; i++) {
    while (l < r && calc(q[l], i) >= calc(q[l + 1], i)) {
      l++;
    }
    dp[i] = calc(q[l], i);
    while (l < r && get_x(q[r], q[r - 1]) >= get_x(q[r], i)) {
      r--;
    }
    q[++r] = i;
  }
  cout << dp[n] << '\n';
  return 0;
}
