    using System;
    using System.Linq;
    using System.Collections.Generic;
    using static System.Math;
 
 
    public class Program
    {
        public static void Main(string[] args)
        {
            int count = int.Parse(Console.ReadLine());
            List<int> number = Console.ReadLine().Split().Select(int.Parse).ToList();
            int f = 0;
            int n = 1;

            while(true)
            {
                int stock = number.Select(x => n % x).Sum();

                if (n > Pow(10,5)) break;

                if (f < stock) f = stock;
                n++;
            }

            Console.WriteLine(f);
        }
    }