#include <bits/stdc++.h>
using namespace std;
const int MX = 1000000 + 5;
const long long inf = 1e18;
const long long mod = 1e16 + 7;
pair<long long, long long> st[MX];
double IP[MX];
int top;
double intersect(pair<long long, long long> a, pair<long long, long long> b) {
  return (b.second - a.second) / (double)(a.first - b.first);
}
void insert(pair<long long, long long> candidate) {
  while (top > 0 &&
         intersect(st[top - 1], st[top]) >= intersect(st[top - 1], candidate))
    top--;
  st[++top] = candidate;
  IP[top] = intersect(st[top - 1], candidate);
}
long long Q(long long x) {
  int up = upper_bound(IP + 1, IP + top + 1, x) - IP - 1;
  return st[up].first * x + st[up].second;
}
void init(pair<long long, long long> candidate = {inf, 0}, double base = -inf) {
  top = 0;
  st[0] = candidate;
  IP[0] = base;
  insert({0, 0});
}
long long a[MX], b[MX];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) cin >> b[i];
  init();
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    ans = Q(a[i]);
    insert({b[i], ans});
  }
  cout << ans << endl;
  return 0;
}
