#include <bits/stdc++.h>
using namespace std;
long long int a[100001];
long long int b[100001];
long long int dp[100001];
long long int q[100001];
long long int cord(int index1, int index2) {
  return (dp[index2] - dp[index1]) / (b[index1] - b[index2]);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int temp;
    scanf("%d", &temp);
    a[i] = temp;
  }
  for (int i = 0; i < n; i++) {
    int temp;
    scanf("%d", &temp);
    b[i] = temp;
  }
  int begin1 = 0;
  int end1 = 0;
  for (int i = 1; i < n; i++) {
    while (begin1 < end1 && (dp[q[begin1 + 1]] - dp[q[begin1]]) /
                                    (b[q[begin1]] - b[q[begin1 + 1]]) <
                                a[i]) {
      begin1++;
    }
    dp[i] = dp[q[begin1]] + a[i] * b[q[begin1]];
    while (begin1 < end1 && cord(q[end1 - 1], q[end1]) > cord(q[end1], i)) {
      end1--;
    }
    end1++;
    q[end1] = i;
  }
  printf("%lld\n", dp[n - 1]);
  return 0;
}
