#include <bits/stdc++.h>
using namespace std;
long long dp[111111], f[111111];
int st[111111], de[111111];
int n, a[111111], b[111111], l, r, mid, now, tail;
long long cost(int x, int y) { return ((long long)(b[x])) * a[y]; }
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  a[n + 1] = a[n] + 1;
  for (int i = 1; i <= n; i++) scanf("%d", &b[i]);
  st[now = tail = 1] = 0;
  de[1] = 1;
  for (int i = 2; i <= n; i++) {
    if (st[now + 1] == i) now++;
    dp[i] = dp[de[now]] + cost(de[now], i);
    while (i < st[tail] &&
           dp[i] + cost(i, st[tail]) <= dp[de[tail]] + cost(de[tail], st[tail]))
      tail--;
    l = max(i + 1, st[tail]);
    r = n + 1;
    mid = (l + r) / 2;
    while (l < r) {
      if (dp[i] + cost(i, mid) <= dp[de[tail]] + cost(de[tail], mid))
        r = mid;
      else
        l = mid + 1;
      mid = (l + r) / 2;
    }
    st[++tail] = mid;
    de[tail] = i;
  }
  cout << dp[n] << endl;
}
