#include <bits/stdc++.h>
using namespace std;
const int maxn = 100100;
int q[maxn];
int n, a[maxn], b[maxn];
long long dp[maxn];
int X(long long x1, long long y1, long long x2, long long y2) {
  if (x1 == 0) {
    if (x2 == 0) return 0;
    return -1;
  }
  if (x2 == 0) return 1;
  long long k1 = y1 / x1;
  long long r1 = y1 % x1;
  long long k2 = y2 / x2;
  long long r2 = y2 % x2;
  if (k1 < k2) return -1;
  if (k1 > k2) return 1;
  return -X(r1, x1, r2, x2);
}
int main() {
  while (~scanf("%d", &n)) {
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (int i = 1; i <= n; i++) scanf("%d", &b[i]);
    dp[1] = b[1];
    int l = 1, r = 1;
    q[1] = 1;
    for (int i = 2; i <= n; i++) {
      while (l + 1 <= r && dp[q[l + 1]] + 1LL * (a[i] - 1) * b[q[l + 1]] <=
                               dp[q[l]] + 1LL * (a[i] - 1) * b[q[l]])
        l++;
      dp[i] = dp[q[l]] + 1LL * (a[i] - 1) * b[q[l]] + b[i];
      while (l + 1 <= r &&
             X(-b[i] + b[q[r]], dp[i] - dp[q[r]], -b[q[r]] + b[q[r - 1]],
               dp[q[r]] - dp[q[r - 1]]) <= 0)
        r--;
      q[++r] = i;
    }
    printf("%I64d\n", dp[n]);
  }
}
