#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
#include <numeric>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main(void) {

    int N; cin>>N;
    vector<int> a(N);
    for(int i=0; i<N; i++)  cin>>a[i];

    int leastCommonMultiple=a[0];
    for (int i = 0; i < N; ++i) leastCommonMultiple = lcm(leastCommonMultiple,a[i]);
    int ans = 0;
    for (int i = 0; i < leastCommonMultiple; ++i) {
        int tmp = 0;
        for (int j = 0; j < N; ++j) {
            tmp += i % a[j];
        }
        ans = max(ans, tmp);
    }
    cout<<ans<<endl;

    return 0;
}