#include <stdio.h>
int main(void)
{
    int N;
    scanf("%d", &N);

    int numbers[N];
    for(int i=0; i<N; i++){
        scanf("%d", &numbers[i]);
    }

    // 入力した値の最小公倍数を求めるプログラムを作成
    int count = 1;
    int amari[N];
    int sum_amari;
    int saisyou_koubaisuu;
    while(1){
        sum_amari = 0;
        for(int i=0; i<N; i++){
            //amari[i] = count%numbers[i];
            //sum_amari += amari[i];
            sum_amari += count%numbers[i]
        }
        if(sum_amari == 0){
            saisyou_koubaisuu = count;
            break;
        }
        count++;
    }
    // printf("saisyou_koubaisuu = %d\n", saisyou_koubaisuu);

    int f;
    int ans = -1;
    for(int i=0; i<saisyou_koubaisuu; i++){
        f = 0;
        for(int j=0; j<N; j++){
            f += i%numbers[j];
        }
        if(ans < f){
            ans = f;
        }
        // printf("%d %d\n", i, f);
    }

    printf("%d\n", ans);

    return 0;
}
