package ua.nure.jfn.task1;

public class Part2 {

	static void main(String[] args) {
		int num = parseInt(args[0]);

		int overallGcd = num;
		int overallLcm = num;

		for (int i = 1; i < args.length; i++) {
			num = parseInt(args[i]);
			overallGcd = gcd(overallGcd, num);
			overallLcm = lcm(overallLcm, num);
		}

		System.out.printf("%d %d", overallGcd, overallLcm);
	}

	static int pow(int num, int power) {
		int result = 1;
		for (int i = 0; i < power; i++) {
			result *= num;
		}

		return result;
	}

	static int parseInt(String str) {
		int number = 0;
		int digitPlace = 0;
		char[] chArray = str.toCharArray();

		for (int i = chArray.length - 1; i >= 0; i--) {
			char ch = chArray[i];
			if (ch >= '0' && ch <= '9') {
				number += (ch - '0') * pow(10, digitPlace++);
			} else {
				digitPlace = 0;
			}
		}

		return number;
	}

	static int gcd(int a, int b) {
		for (int min = a < b ? a : b; min > 1; min--)
			if (a % min == 0 && b % min == 0)
				return min;
		return 1;
	}

	static int lcm(int a, int b) {
		return (a * b) / gcd(a, b);
	}
}
