import math
from functools import reduce

n = int(input())
a = [int(i) for i in input().split()]

ans1 = ans2 = 0
li_ans = []


def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


lcm = lcm_list(a)

for num in a:
    ans1 += (lcm - 1) % num
    ans2 += (lcm + 1) % num

print(max(ans1, ans2))
