#include <bits/stdc++.h>
using namespace std;
const int NMax = 110000;
int N;
long long A[NMax], B[NMax], dp[NMax];
int Q[NMax], L, R;
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) scanf("%I64d", A + i);
  for (int i = 1; i <= N; i++) scanf("%I64d", B + i);
  L = 0;
  R = 0;
  Q[L] = 1;
  for (int i = 2; i <= N; i++) {
    while (R > L &&
           (double)(dp[Q[L + 1]] - dp[Q[L]]) / (B[Q[L]] - B[Q[L + 1]]) <
               (double)A[i])
      L++;
    dp[i] = dp[Q[L]] + B[Q[L]] * A[i];
    Q[++R] = i;
    while (R > L + 1) {
      int c = R, b = R - 1, a = R - 2;
      if ((double)(dp[Q[c]] - dp[Q[b]]) / (B[Q[b]] - B[Q[c]]) <
          (double)(dp[Q[b]] - dp[Q[a]]) / (B[Q[a]] - B[Q[b]])) {
        Q[b] = Q[c];
        R--;
      } else
        break;
    }
  }
  printf("%I64d\n", dp[N]);
  getchar();
  getchar();
  return 0;
}
