#include <bits/stdc++.h>
using namespace std;
long long a[100005], b[100005], dp[100005], q[100005];
int main() {
  ios::sync_with_stdio(false);
  long long i, j, k, n, s, e;
  cin >> n;
  for (i = 0; i < n; ++i) cin >> a[i];
  for (i = 0; i < n; ++i) cin >> b[i];
  dp[0] = 0, dp[1] = b[0] * a[1];
  s = 0, e = 2;
  q[0] = 0, q[1] = 1;
  for (i = 2; i < n; ++i) {
    while (s + 1 < e &&
           (dp[q[s + 1]] - dp[q[s]]) < a[i] * (b[q[s]] - b[q[s + 1]]))
      s++;
    dp[i] = dp[q[s]] + b[q[s]] * a[i];
    while (s <= e - 2 &&
           (double)(dp[i] - dp[q[e - 1]]) * (b[q[e - 2]] - b[q[e - 1]]) <=
               (double)(dp[q[e - 1]] - dp[q[e - 2]]) * (b[q[e - 1]] - b[i]))
      e--;
    q[e++] = i;
  }
  cout << dp[n - 1] << endl;
  return 0;
}
