#include <bits/stdc++.h>
using namespace std;
const int MAXN = 111111;
const int oo = (int)(1e9);
const long long OO = (long long)(1e18);
int MOD = 1000000007;
const long double PI = 3.141592653589793;
template <typename TT>
void read(TT &x) {
  char ch;
  for (ch = getchar(); ch > '9' || ch < '0'; ch = getchar())
    ;
  for (x = 0; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - 48;
}
int n;
long long a[111111], b[111111], s[111111], f[111111];
int Q[111111], L, R;
void Init() {
  scanf("%d", &n);
  ;
  s[0] = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    ;
    s[i] = s[i - 1] + a[i];
  }
  for (int i = 1; i <= n; i++) scanf("%d", &b[i]);
  ;
  f[1] = 0;
  Q[L = R = 0] = 1;
  for (int i = 2; i <= n; i++) {
    while (L < R) {
      int u = Q[L], v = Q[L + 1];
      if (a[i] * (b[u] - b[v]) > f[v] - f[u])
        L++;
      else
        break;
    }
    f[i] = (f[Q[L]] + b[Q[L]] * a[i]);
    while (L < R) {
      int u = Q[R - 1], v = Q[R];
      if ((long double)(f[v] - f[u]) / (b[u] - b[v]) >
          (long double)(f[i] - f[v]) / (b[v] - b[i]))
        R--;
      else
        break;
    }
    Q[++R] = i;
  }
  cout << f[n];
}
int main() {
  Init();
  return 0;
}
