using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.IO;
using System.Text;
using System.Diagnostics;

class Program
{
    static void Main()
    {
        long n = long.Parse(Console.ReadLine());
        long[] a = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        long ans = 0;
        long max = a[0];

        for (long i = 0; i < n; i++)
        {
            max = lcm(a[i], max);
        }
        long dist = sieve(max) - 1;
        long target = max - dist;
        for(long i = 0; i < n; i++)
        {
            ans += target % a[i];
        }
        Console.WriteLine(ans);
    }
    public static long gcd(long a, long b)
    {
        while (b > 0) { var t = a % b; a = b; b = t; }
        return a;
    }
    public static long lcm(long a, long b) => a / gcd(a, b) * b;
    public static long sieve(long n)
    {
        for (long i = 2; i <= n; i++)
        {
            if(n % i == 0)
            {
                return i;
            }
        }
        return n;
    }
}
