#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;

int main() {
	int N;	cin >> N;
	vector<int> a;
	int inputA;
	int num;
	vector<int> answer;
	for (int i = 0; i < N; ++i) {
		cin >> inputA;
		a.push_back(inputA);
	}
	for (int i = 1; i <= pow(*max_element(a.begin(), a.end()),3); ++i) {
		num = 0;
		for (int j = 0; j < N; ++j) {
			num += i % a[j];
		}
		answer.push_back(num);
	}
	cout << *max_element(answer.begin(), answer.end());
	cin >> N;
	return 0;
}