using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication4
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');
            var list_f = new List<int>();
            for (int i = 1; i < 1000000; i++)
            {
                int mod_f = 0;
                foreach (string c in input)
                {
                    mod_f += i % int.Parse(c);
                }
                list_f.Add(mod_f);
            }
            int max = list_f.Max();
            Console.WriteLine(max);
        }
    }
}
