#!/usr/bin/env python3
import sys
import math

def lcm(a,b):
    return a * b // math.gcd(a,b)

def solve(N: int, a: "List[int]"):
    a_lcm = a[0]
    for i in range(1,N):
        a_lcm = lcm(a_lcm,a[i])
    
    l = []
    for m in range(a_lcm):
        sum = 0
        for i in range(N):
            sum += m % a[i]
        l.append(sum)

    print((sorted(l,reverse=True))[0])
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()
