#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 100;
long long a[N], b[N], dp[N], q[N];
long long n, sz, pt;
inline long long count(long long x, long long y) { return dp[x] + a[y] * b[x]; }
inline long double better(long long x, long long y) {
  return 1. * (dp[y] - dp[x]) / (b[x] - b[y]);
}
int32_t main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  for (long long i = 0; i < n; i++) cin >> a[i];
  for (long long i = 0; i < n; i++) cin >> b[i];
  q[sz++] = 0;
  for (long long i = 1; i < n; i++) {
    while (pt + 1 < sz && count(q[pt + 1], i) < count(q[pt], i)) pt++;
    dp[i] = count(q[pt], i);
    while (pt < sz && sz >= 2 &&
           better(q[sz - 2], i) < better(q[sz - 2], q[sz - 1]))
      sz--;
    q[sz++] = i;
  }
  return cout << dp[n - 1], 0;
}
