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

namespace AtCoder_Project_CSharp
{
    class Program
    {

        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int ans = 0;
            for (int i = 1; i < 100000; i++)
            {
                int tmp = F(i, a);
                if (ans < tmp) ans = tmp;
            }
            Console.WriteLine(ans);

        }

        static int F(int m,IEnumerable<int> ie)
        {
            return ie.Sum((e) => m % e);
        }
    }
}
