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

int main()
{
    int N;
    std::cin >> N;

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

    int M = std::accumulate(std::begin(a), std::end(a), 0);

    int ans = 0;
    for (int i = 1; i <= M; i++) {
        int f = 0;
        for (int j = 0; j < N; j++) {
            f += (i % a[j]);
        }
        ans = std::max(ans, f);
    }

    std::cout << ans << std::endl;

    return 0;
}