#include<stdio.h>
#include<string.h>

// helpful functions
#define fl(i,n) for(int i = 0; i < n; i++)
#define fls(i,a,b) for(int i = a; i <= b; i++) // flexible for loop
#define fls2(i,a,b) for(int i = a; i >= b; i--) // flexible for loop 2
#define afl(i,a,n) int a[n]; for(int i = 0; i < n; i++) scanf("%d", &a[i])

// printers
#define iprint(x) printf("%d\n", x)
#define lprint(x) printf("%lld\n", x)
#define fprint(x) printf("%.f\n", x)
#define dprint(x) printf("%.lf\n", x)
#define cprint(x) printf("%c\n", x)
#define sprint(x) printf("%s\n", x)

// scanners
#define iscan(x) scanf("%d", &x)
#define lscan(x) scanf("%lld", &x)
#define fscan(x) scanf("%f", &x)
#define dscan(x) scanf("%lf", &x)
#define cscan(x) scanf("%c\n", &x)
#define scan(x) scanf("%s", x)

// special scanners
#define escan(x) scanf("%[^\n]", x)

// quick scanners
#define qs(x) int x; scanf("%d", &x)
#define ls(x) long long x; scanf("%lld", &x)
#define fs(x) float x; scanf("%f", &x)
#define ds(x) double x; scanf("%lf", &x)
#define cs(x) char x; scanf("%lf", &x)
#define ss(x,n) char x[n]; scanf("%s", &x)
#define es(x,n) char x[n]; scanf("%[^\n]", &x)

typedef long long ll;
typedef double db;

int main()
{
	qs(a); qs(b); qs(c); qs(d);
	iprint(a*d - b*c);
}
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
int a[20],b[110],n;bool bk[20];ll Ans=5e18;
void dfs(int k){
	if(k>15){
		bool PD=true;
		for(int i=1;i<=n;i++){
			bool pd=false;
			for(int j=1;j<=15;j++)
				if(bk[j]&&b[i]%a[j]==0) {pd=true;break;}
			if(!pd) {PD=false;break;}
		}
		if(PD){
			ll Sum=1;
			for(int i=1;i<=15;i++)
				if(bk[i]) Sum*=a[i];
			if(Ans>Sum) Ans=Sum;
		}
		return ;
	}
	bk[k]=true;dfs(k+1);
	bk[k]=false;dfs(k+1);
}
int main()
{
	a[1]=2;a[2]=3;a[3]=5;a[4]=7;a[5]=11;
	a[6]=13;a[7]=17;a[8]=19;a[9]=23;a[10]=29;
	a[11]=31;a[12]=37;a[13]=41;a[14]=43;a[15]=47;
	memset(bk,false,sizeof(bk));
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&b[i]);
	dfs(1);
	printf("%lld\n",Ans);
	return 0;
}