#include <bits/stdc++.h>
using namespace std;
long long a[100005], b[100005], dp[100005];
int q[100005];
double h(int x, int y) { return (dp[x] - dp[y]) / (b[x] - b[y]); }
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    for (int i = 1; i <= n; i++) scanf("%I64d", &a[i]);
    for (int i = 1; i <= n; i++) scanf("%I64d", &b[i]);
    memset(dp, 0, sizeof(dp));
    int head = 0, tail = 0;
    q[0] = 1;
    for (int i = 2; i <= n; i++) {
      while (head < tail && (dp[q[head + 1]] + a[i] * b[q[head + 1]]) <
                                (dp[q[head]] + b[q[head]] * a[i]))
        head++;
      dp[i] = dp[q[head]] + a[i] * b[q[head]];
      while (head < tail && (h(i, q[tail]) > h(q[tail], q[tail - 1]))) tail--;
      q[++tail] = i;
    }
    printf("%I64d\n", dp[n]);
  }
  return 0;
}
