#include <bits/stdc++.h>
using namespace std;
long long int powmod(long long int base, long long int pow) {
  long long int res = 1;
  while (pow) {
    if (pow % 2 != 0) res = (res * base) % 1000000007;
    base = (base * base) % 1000000007;
    pow /= 2;
  }
  return res;
}
long long int dp[(long long int)100001], a[(long long int)100001],
    b[(long long int)100001], in[(long long int)100001];
double m(int x, int y) { return (1.0 * dp[x] - dp[y]) / (1.0 * b[x] - b[y]); }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n;
  cin >> n;
  for (long long int i = 0; i < n; i++) cin >> a[i];
  for (long long int i = 0; i < n; i++) cin >> b[i];
  dp[0] = 0;
  long long int l = 0, r = 0;
  for (long long int i = 1; i < n; i++) {
    while (l < r and m(in[l], in[l + 1]) > -a[i]) l++;
    dp[i] = dp[in[l]] + b[in[l]] * a[i];
    while (r > l and m(in[r], i) > m(in[r - 1], in[r])) r--;
    r++;
    in[r] = i;
  }
  cout << dp[n - 1] << "\n";
}
