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]);
            }
            Array.Sort(Mods);
            int LCM = 1;
            for (int i = 0; i < Mods.Length; i++) {
                if (LCM > Mods[i]) {
                    LCM *= getLCM(LCM, Mods[i]);
                } else {
                    LCM *= getLCM(Mods[i], LCM);
                }
                if (i == 0) i++;
            }
            int answer = 1;
            for (int i = 1; i < LCM; i++) {
                answer = Math.Max(answer, Mod(i, Mods));
            }
            Console.WriteLine(answer);
        }

        static int getGCD(int m, int n) {
            if (n == 0) return m;
            return getGCD(n, n % m);
        }

        static int getLCM(int m, int n) {
            return m * n / getGCD(m, n);
        }
        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;
        }
    }
}
