#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
long long dp[N], a[N], b[N];
bool CompTwo(int j, int k, long long sum) {
  return (double)(dp[j] - dp[k]) / (double)(b[j] - b[k]) >= sum;
}
bool CompThree(int i, int j, int k) {
  return (double)(dp[j] - dp[i]) / (double)(b[j] - b[i]) <=
         (double)(dp[k] - dp[j]) / (double)(b[k] - b[j]);
}
int ls[N], front, rear;
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));
    front = rear = 0;
    dp[1] = 0;
    ls[rear++] = 1;
    for (int i = 2; i <= n; i++) {
      while (rear - front > 1 && CompTwo(ls[front + 1], ls[front], -a[i]))
        front++;
      int k = ls[front];
      dp[i] = dp[k] + b[k] * a[i];
      while (rear - front > 1 && CompThree(ls[rear - 2], ls[rear - 1], i))
        rear--;
      ls[rear++] = i;
    }
    printf("%I64d\n", dp[n]);
  }
  return 0;
}
