#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-1;
int cmp(double x) { return (x > eps) - (x < -eps); }
struct P {
  long long x, y;
  P() {}
  P(long long a, long long b) : x(a), y(b) {}
  P operator-(const P &a) const { return P(x - a.x, y - a.y); }
} q[100000 + 5];
int cross(P a, P b) { return cmp((double)a.x * b.y - (double)a.y * b.x); }
int a[100000 + 5], b[100000 + 5];
long long dp[100000 + 5];
int main() {
  int n;
  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]);
  int front = 0, rear = -1;
  dp[1] = 0;
  q[++rear] = P(-b[1], dp[1]);
  for (int i = 2; i <= n; i++) {
    while (front < rear && cross(q[front + 1] - q[front], P(1, a[i])) >= 0)
      front++;
    dp[i] = q[front].y - q[front].x * a[i];
    P tmp(-b[i], dp[i]);
    while (front < rear && cross(tmp - q[rear], q[rear] - q[rear - 1]) >= 0)
      rear--;
    q[++rear] = tmp;
  }
  printf("%I64d\n", dp[n]);
  return 0;
}
