#include <bits/stdc++.h>
using namespace std;
void stop() {
  printf("press any key to continue...\n");
  while (getchar() != '\n') {
  }
}
int n;
long long a[100050], b[100050], dp[100050];
int q[100050];
double f(int n, int m) { return (double)(dp[m] - dp[n]) / (b[n] - b[m]); }
int main() {
  istream& in = cin;
  in >> n;
  for (int i = 0; i < n; i++) {
    in >> a[i];
  }
  for (int i = 0; i < n; i++) {
    in >> b[i];
  }
  int s, e;
  s = e = 0;
  q[e++] = 0;
  dp[0] = 0;
  for (int i = 1; i < n; i++) {
    while (s + 1 < e) {
      long long one = dp[q[s]] + b[q[s]] * a[i];
      long long two = dp[q[s + 1]] + b[q[s + 1]] * a[i];
      if (two < one) {
        s++;
      } else {
        break;
      }
    }
    dp[i] = dp[q[s]] + b[q[s]] * a[i];
    while (s + 1 < e) {
      if (f(q[e - 1], i) < f(q[e - 2], q[e - 1])) {
        e--;
      } else {
        break;
      }
    }
    q[e++] = i;
  }
  cout << dp[n - 1] << endl;
}
