using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var r = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int ret = 0;
            for (int i = 2; i <= 1000000; i++)
            {
                var tmpRet = 0;
                for (int j = 0; j < N; j++)
                {
                    tmpRet += i % r[j];
                }

                if (tmpRet >= ret)
                {
                    ret = tmpRet;
                }
            }
            Console.WriteLine(ret);
        }
        
    }
}