def main():
        run()

def run():
        n = int(input())
        data = [int(x) for x in input().split(" ")]

        max_sum = -1
        max_m = max(data)
        for m in range(max_m):
                max_sum = max(max_sum, calc(m, data))
        print(max_sum)


def calc(m, numbers):
        sum_ = 0
        for num in numbers:
                sum_ += m % num  
        return sum_

if __name__ == "__main__":
        main()