#include <bits/stdc++.h>
using namespace std;
unsigned long long a[1111111];
unsigned long long b[1111111];
unsigned long long dp[1111111];
int qe[1111111];
unsigned long long getU(int j, int k) { return dp[j] - dp[k]; }
unsigned long long getD(int j, int k) { return b[k] - b[j]; }
double fk(int j, int k) { return (double)(dp[j] - dp[k]) / (b[k] - b[j]); }
unsigned long long getDP(int i, int j) { return dp[j] + b[j] * a[i]; }
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) cin >> b[i];
  memset(dp, -1, sizeof(dp));
  int l = 0, r = 0;
  qe[r++] = 1;
  dp[1] = 0;
  for (int i = 2; i <= n; i++) {
    while (l + 1 < r && fk(qe[l + 1], qe[l]) <= a[i]) l++;
    dp[i] = getDP(i, qe[l]);
    while (l + 1 < r && fk(i, qe[r - 1]) <= fk(qe[r - 1], qe[r - 2])) r--;
    qe[r++] = i;
  }
  cout << dp[n] << endl;
  return 0;
}
