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

namespace workspace
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] an = Console.ReadLine()
                .Split(' ')
                .Select(int.Parse)
                .ToArray();
            int f = 0;

            Array.Sort(an);
            int m = 0;
            int max = an[an.Length - 1];
            for(int i = 0; i < an.Length; i++)
            {
                m = Lcm(an[i], an[i + 1]);
            }



            for (int i = 0; i < N; i++)
            {
                f += m % an[i];
            }

            Console.WriteLine(f);
        }

        // 最小公倍数
        public static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }

        
        public static int Gcd(int a, int b)
        {
            if (a < b)
                
                return Gcd(b, a);
            while (b != 0)
            {
                var remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }



    }
}

