/*#include <iostream>
#include <stdio.h>
using namespace std;
int memo[1000][101000]={{0,},};
int N;
int V[1000];
int W[1000];
int f(int n,int w)
{
if(w < 0)
{
return -2147483630;
}
if(n == N)
{
return 0;
}
if(memo[n][w]!=0)
{
//printf("memo[%d][%d] = %d\n",n,w,memo[n][w]);
return memo[n][w];
}
int a,b;
int temp;
a = f(n+1,w);
b = f(n+1,w-W[n])+V[n];
memo[n][w] = a>b?a:b;
//printf("memo[%d][%d] = %d, %d %d %s\n",n,w,memo[n][w],a,b,a>b?"don\'t eat":"eat");
return memo[n][w];
}
int main()
{
int w;
int i,j;
scanf("%d %d",&N,&w);
for(i =0;i < N;i++)
{
scanf("%d %d",&W[i],&V[i]);
}
printf("%d",f(0,w));
return 0;
}
*/
#include <iostream>
#include <stdio.h>
#include <stack>
#include <queue>
using namespace std;
int num;
long long a[100100];
long long b[100100];
long long memo[100100];
priority_queue<int> asfa;
long long f(int n)
{
if(memo[n]!=0)
{
return memo[n];
}
if(n == num-1)
{
return 0;
}
int i;
int temp = n+1;
long long int c;
long long small = b[n] * a[num-1];
long long fast = b[n] * a[num-1];
for(i = n+1; i < num-1; i++)
{
if(i == n+1)
{
if(a[i]*b[n]+a[num-1]*b[i] > small)
{
continue;
}
}
else if(a[i]*b[n]+a[num-1]*b[i] > a[temp]*b[n]+a[num-1]*b[temp])
{
continue;
}
c = f(i) + a[i]*b[n];
if(c < small)
{
small = c;
}
temp = i;
}
memo[n] = small;
return small;
}
int main()
{
int i;
scanf("%d",&num);
for(i = 0; i < num; i++)
{
scanf("%d",&a[i]);
}
for(i = 0; i < num; i++)
{
scanf("%d",&b[i]);
}
printf("%lld",f(0));
return 0;
}



