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