#include <bits/stdc++.h>
using namespace std;
long long n;
vector<long long> a, b;
const long long INF = 1e18;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  a.resize(n);
  b.resize(n);
  for (long long i = 0; i < n; ++i) cin >> a[i];
  for (long long i = 0; i < n; ++i) cin >> b[i];
  long long dp[n];
  long double fr[n];
  vector<long long> st;
  for (long long i = 0; i < n; ++i) {
    dp[i] = INF;
    fr[i] = INF;
  }
  dp[0] = 0;
  fr[0] = -INF;
  long long pos = 0;
  st.push_back(0);
  for (long long i = 1; i < n; ++i) {
    while (pos < (long long)st.size() && fr[pos] < a[i]) {
      pos++;
    }
    if (fr[pos] > a[i]) {
      pos--;
    }
    long long j = st[pos];
    dp[i] = dp[j] + a[i] * b[j];
    long double first = -INF;
    while (1) {
      long long j = st.back();
      first = (long double)(dp[j] - dp[i]) / (b[i] - b[j]);
      if (first > fr[(long long)st.size() - 1]) break;
      st.pop_back();
    }
    st.push_back(i);
    fr[(long long)st.size() - 1] = first;
  }
  cout << dp[n - 1] << endl;
}
