import numpy as np
def piyo():
    _ = int(input())
    b = np.array(list(int(i) for i in input().split()),dtype=int)
    fuga = []
    piyopiyo = []
    for hoge in range(10 ** 5):
        for hogehoge in b:
            piyopiyo.append((hoge+1)%hogehoge)
        fuga.append(np.sum(piyopiyo))
        piyopiyo.clear()
    print(max(fuga))
        
if __name__ == '__main__':
    piyo()