N = int(input())
a = input().split()
a = [int(i) for i in a]
res_list = []
for i in range(10 ** 10):
    res = 0
    if i >= 2 and i% 2 == 0:
        if res_list[:i//2] == res_list[i//2:]:
            break
    for j in a:
        res += i % j
    res_list.append(res)
    
print(max(res_list))