#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
long long n, k[100007], x[100007], cur, dp[100007], ended[100007], last, L, R,
    mid;
vector<pair<long long, long long> > stek;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  for (long long i = 0; i < n; i++) cin >> x[i];
  for (long long i = 0; i < n; i++) cin >> k[i];
  cur = 0;
  dp[0] = 0;
  ended[0] = 1e16;
  for (long long i = 1; i < n; i++) {
    while (stek.size() > 1) {
      last = stek.size() - 1;
      if (ended[last - 1] > (-dp[i - 1] + stek[last - 1].second) /
                                (k[i - 1] - stek[last - 1].first))
        stek.pop_back();
      else
        break;
    }
    stek.push_back({k[i - 1], dp[i - 1]});
    if (stek.size() > 1) {
      last = stek.size() - 1;
      ended[last - 1] = (-stek[last].second + stek[last - 1].second) /
                        (stek[last].first - stek[last - 1].first);
      ended[last] = 1e16;
    }
    L = 0, R = stek.size();
    while (R - L > 0) {
      mid = (R + L) / 2;
      if (x[i] > ended[mid])
        L = mid + 1;
      else
        R = mid;
    }
    dp[i] = stek[L].first * x[i] + stek[L].second;
  }
  cout << dp[n - 1];
}
