#coding: utf-8

iN = int(input())
iAList = list(map(int, input().split()))

iMax = max(iAList) * 1000
iResult = []
for m in range(1, iMax):
    iModSum = 0
    for i2 in range(len(iAList)):
        iModSum += (m % iAList[i2])
    iResult.append(iModSum)

print (max(iResult))