import numpy as np
N = int(input())
alist = np.array(list(map(int, input().split())))
ranges = np.arange(1, 10**5)


def f(m):
    return np.sum(np.mod(alist, m))


num_f = np.frompyfunc(f, 1, 1)
print(max(num_f(ranges)) - N)
