#include <bits/stdc++.h>
using namespace std;
long long int h[100005], c[100005], DP[100005];
pair<long long int, long long int> A[100005];
double intersection(pair<long long int, long long int> x,
                    pair<long long int, long long int> y) {
  return (((double)x.second - y.second) / (y.first - x.first));
}
int query(int l, int r, int q) {
  int mid, ans;
  ans = 1;
  while (l <= r) {
    mid = (l + r) >> 1;
    if (q >= intersection(A[mid], A[mid - 1])) {
      ans = mid;
      l = mid + 1;
    } else
      r = mid - 1;
  }
  return ans;
}
int main() {
  int n, i, q, k;
  double x;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%lld", &h[i]);
  for (i = 1; i <= n; i++) scanf("%lld", &c[i]);
  A[1] = make_pair(c[1], 0);
  k = 1;
  DP[1] = 0;
  for (i = 2; i <= n; i++) {
    q = query(2, k, h[i]);
    DP[i] = A[q].first * h[i] + A[q].second;
    while (k > 1) {
      x = intersection(make_pair(c[i], DP[i]), A[k - 1]);
      if (intersection(A[k], A[k - 1]) >= x)
        k--;
      else
        break;
    }
    k++;
    A[k] = make_pair(c[i], DP[i]);
  }
  printf("%lld\n", DP[n]);
  return 0;
}
