#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
using namespace std;
#define re(i, n) for (int i=0; i<n; i++)
#define re1(i, n) for (int i=1; i<=n; i++)
#define re2(i, l, r) for (int i=l; i<r; i++)
#define re3(i, l, r) for (int i=l; i<=r; i++)
#define rre(i, n) for (int i=n-1; i>=0; i--)
#define rre1(i, n) for (int i=n; i>0; i--)
#define rre2(i, r, l) for (int i=r-1; i>=l; i--)
#define rre3(i, r, l) for (int i=r; i>=l; i--)
#define ll long long
const int MAXN = 100010;
const double zero = 1e-7, INF = 1e10, INF0 = 1e20;
struct qnode {
double x; int No;
} Q[MAXN + 1];
int n, A[MAXN], B[MAXN], front, rear;
ll F[MAXN], res;
void init()
{
scanf("%d", &n);
re1(i, n) scanf("%d", &A[i]);
re1(i, n) scanf("%d", &B[i]);
}
double f01(int a1, ll b1, int a2, ll b2)
{
if (a1 == a2) return INF0; else return (double) (b2 - b1) / (a1 - a2);
}
void ins(int z)
{
int a0 = A[z + 1]; ll b0 = F[z]; double x1 = 0;
if (front <= rear && b0 == F[Q[front].No]) {
if (a0 <= A[Q[front].No + 1]) return; else {x1 = Q[front].x; front++;}
}
double x2, _x; int No0;
while (front <= rear) {
x2 = Q[front].x; No0 = Q[front].No;
_x = f01(a0, b0, A[No0 + 1], F[No0]);
if (_x + zero >= x1 && _x + zero < x2) {Q[--front].x = _x; Q[front].No = z; return;} else {x1 = x2; front++;}
}
Q[--front].x = INF; Q[front].No = z;
}
void solve()
{
F[0] = F[1] = 0; front = n; rear = n - 1; ins(0);
int l, r, mid;
re3(i, 2, n) {
l = front; r = rear;
while (l < r) {
mid = l + r >> 1;
if (Q[mid].x + zero >= B[i]) r = mid; else l = mid + 1;
}
F[i] = F[Q[l].No] + (ll) A[Q[l].No + 1] * B[i];
if (F[i - 1] > F[i]) F[i] = F[i - 1];
ins(i - 1);
}
res = F[n];
}
void pri()
{
cout << res << endl;
}
int main()
{
init();
solve();
pri();
return 0;
}
I2luY2x1ZGUgPG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