public static void main(String[] args) {
		Random gen = new Random();
		int n = 5;
		// random tests for n = 40, k = 4 for 100 times
		for (int times = 0; times < 100; ++times) {
			List<Integer> A = new ArrayList<Integer>();
			for (int i = 0; i < n; ++i) {
				A.add(gen.nextInt(100));
			}
			System.out.println("n = " + n);
			System.out.println(check_ans(A));
			System.out.println(max_profit_unlimited_pairs(A));
			assert (check_ans(A) == max_profit_unlimited_pairs(A));
		}

		// For input
		if (args.length == 1) {
			n = Integer.valueOf(args[0]);
		} else {
			n = gen.nextInt(10000) + 1;
		}
		List<Integer> A = new ArrayList<Integer>();
		for (int i = 0; i < n; ++i) {
			A.add(gen.nextInt(100));
		}
		System.out.println("n = " + n);
		System.out.println(max_profit_unlimited_pairs(A));
	}