#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-12;
const double PI = acos(-1);
const long long INFF = (long long)1e18;
const int INF = (int)1e9;
const int mod = (int)1e9 + 7;
const int MAX = (int)2e5 + 7;
int n;
long long a[MAX], b[MAX];
void init() {
  scanf("%d", &n);
  for (int i = (1); i < (n + 1); ++i) scanf("%lld", a + i);
  for (int i = (1); i < (n + 1); ++i) scanf("%lld", b + i);
  return;
}
int ck[MAX];
long long cost[MAX];
void sol() {
  int ll = 1, rr = 1;
  ck[1] = 1;
  for (int i = (2); i < (n + 1); ++i) {
    if (ll == rr) {
      cost[i] = cost[ck[ll]] + b[ck[ll]] * a[i];
    } else {
      while (ll != rr) {
        long long v1 = cost[ck[ll]] + b[ck[ll]] * a[i];
        long long v2 = cost[ck[ll + 1]] + b[ck[ll + 1]] * a[i];
        if (v1 > v2)
          ll++;
        else {
          cost[i] = v1;
          break;
        }
      }
      if (ll == rr) cost[i] = cost[ck[ll]] + b[ck[ll]] * a[i];
    }
    while (ll != rr) {
      long long d1 = cost[ck[rr]] - cost[ck[rr - 1]];
      long long v1 = b[ck[rr - 1]] - b[ck[rr]];
      long long d2 = cost[i] - cost[ck[rr]];
      long long v2 = b[ck[rr]] - b[i];
      if ((long double)d1 * v2 >= (long double)d2 * v1)
        rr--;
      else
        break;
    }
    ck[++rr] = i;
  }
  printf("%lld\n", cost[n]);
  return;
}
int main(void) {
  init();
  sol();
  return 0;
}
