Problem:
Least Common Multiple

Find the least common multiple (LCM) of given n integers.

Input

n
a1 a2 ... an

n is given in the first line. Then, n integers are given in the second line.

Output

Print the least common multiple of the given integers in a line.

Constraints

2 ≤ n ≤ 10

1 ≤ ai ≤ 1000

Product of given integers ai(i = 1, 2, ... n) does not exceed 231-1

Sample Input 1

3
3 4 6

Sample Output 1

12

Sample Input 2

4
1 2 3 5

Sample Output 2

30

Solution in C (judge verdict: Wrong Answer)

#include<stdio.h>
#include<math.h>

int isprime(int x);

int main(void){
	int n,a[15],i,j,max=0,f,temp;
	scanf("%d",&n);
	temp=1;
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		if(max<a[i]){max=a[i];}
		temp=temp*a[i];
	}
	if(max==2){printf("2\n");return 0;}
	for(i=1;i<=temp;i++){
		if(isprime(i)!=0){
			f=0;
			for(j=0;j<n;j++){
				if(max*i%a[j]!=0){f=1;break;}
			}
			if(f==0){printf("%d\n",max*i);return 0;}
		}
	}
	printf("%d\n",temp);
	return 0;
}

int isprime(int x){
	int i;
	if(x==2){return 1;}
	if(x<2){return 0;}
	for(i=3;i<sqrt(x);i=i+2){
		if(x%i==0){return 0;}
	}
	return 1;
}