using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());
            string[] Key = Console.ReadLine().Split(' ');
            int[] Mods = new int[N];
            for(int i = 0; i < N; i++) {
                Mods[i] = int.Parse(Key[i]);
            }
            int LCM = getLCM(Mods);
            int answer = Mods.Max();
            for (int i = 1; i < LCM; i++) {
                answer = Math.Max(answer, Mod(i, Mods));
            }
            Console.WriteLine(answer);
        }

        static int getLCM(int[] Mods) {
            //最小公倍数を出す。
            int N = Mods.Max();
            while (!isLCM(N, Mods)) {
                N++;
            }
            return N;
        }

        static bool isLCM(int N, int[] Mods) {
            for (int i = 0; i < Mods.Length; i++) {
                if (N % Mods[i] != 0) {
                    return false;
                }
            }
            return true;
        }

        static int Mod(int m,int[] Mods) {
            int sum = 0;
            int N = Mods.Length;
            for(int i = 0; i < N; i++) {
                sum += m % Mods[i];
            }
            return sum;
        }
    }
}
