#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const int INF = 2147483647;
long long A[maxn], B[maxn];
long long dp[maxn];
int dq[maxn];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%lld", &A[i]);
  for (int i = 0; i < n; i++) scanf("%lld", &B[i]);
  dp[0] = 0;
  int l = 0, r = 1;
  dq[0] = 0;
  for (int i = 1; i < n; i++) {
    while (l + 1 < r &&
           dp[dq[l]] + B[dq[l]] * A[i] >= dp[dq[l + 1]] + B[dq[l + 1]] * A[i])
      l++;
    dp[i] = dp[dq[l]] + B[dq[l]] * A[i];
    while (r - 1 > l &&
           (long double)(dp[i] - dp[dq[r - 2]]) / (B[dq[r - 2]] - B[i]) <=
               (long double)(dp[dq[r - 1]] - dp[dq[r - 2]]) /
                   (B[dq[r - 2]] - B[dq[r - 1]]))
      r--;
    dq[r++] = i;
  }
  printf("%lld\n", dp[n - 1]);
  return 0;
}
