#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <limits>
#include <cmath>

using namespace std;

int main(void)
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i)
		cin >> a[i];

	sort(a.begin(), a.end() );

	unsigned long int lcm1;
	lcm1 = lcm(a[0], a[1]);

	for (int i = 2; i < a.size(); i++)
	{
		lcm1 = lcm(lcm1, a[i]);

	}

	int sum = 0;
	int max = 0;

	for (int i = 2; i <= lcm1; i++)
	{
		sum = 0;
		for (int j = 0; j < a.size(); j++)
		{
			sum += i%a[j];
		}

		if(sum > max)
			max = sum;
	}

	cout << max << endl;

	return 0;
}