def main():
    n = int(input())
    a = list(map(int, input().split(" ")))
    
    ys_set = set([(1000,0)])
    for i in range(n):
        ys_set = cal_set(a[i], ys_set)
    
    ans = 0
    for one in ys_set:
        new_ans = one[0]
        if ans < new_ans:
            ans = new_ans
    print(ans)

def cal_set(a_i, ys_set):
    ys_candidsate_set = set([])
    for one in ys_set:
        #buy
        for num_stock in range(one[0]//a_i+1):
            new_y = one[0] - num_stock*a_i
            new_s = one[1] + num_stock
            ys_candidsate_set.add((new_y, new_s))

        #sell
        for num_stock in range(one[1]+1):
            new_y = one[0] + num_stock*a_i
            new_s = one[1] - num_stock
            ys_candidsate_set.add((new_y, new_s))

    return ys_candidsate_set

if __name__=="__main__":
    main()
