#include <iostream>
#include <algorithm>
#include "Log_csv.h"
using namespace std;

void check_array(int*, int);


int main() {

//	bool is_Debug = true;
//	Log_csv Log("log.csv");

	int N; 
	cin >> N;
	int* integer = new int[N];
	for (int i = 0; i < N; i++) {
		cin >> integer[i];
	}
	sort(integer, integer + N);
//	if(is_Debug) Log.WriteArray(integer, N);
	int min_range = integer[0];
	int max_range = 100000;
	int answer = 0;
	
	for (int num_divided = 2147483647; num_divided > min_range + 1; num_divided--) {
		int tmp = 0;
//		if (is_Debug) {
//			Log.Write("num_divided:"); Log.Write(num_divided);
//			Log.NextLine();
//		}
		for (int i = 0; i < N; i++) {
			tmp += num_divided % integer[i];
//			if (is_Debug) Log.Write(num_divided % integer[i]);
		}
//		if (is_Debug) {
//			Log.NextLine();
//			Log.Write("answer:"); Log.Write(answer); Log.NextLine();
//			Log.Write("tmp:"); Log.Write(tmp); Log.NextLine();
//		}
		if (answer < tmp)answer = tmp;
	}
	
	cout << answer << endl;
	
	delete [] integer;
	return 0;
}

void check_array(int* array, int array_size) {
	cout << "配列の中身" << endl;
	for (int i = 0; i < array_size; i++) {
		cout << array[i] << endl;
	}
}