# -*- coding: utf-8 -*-
# 整数の入力
n = int(input())
# スペース区切りの整数の入力
list = list(map(int, input().split()))

max = 0
for for_mod_num in range(100):
    total = 0
    for i in range(n):
        total += for_mod_num % list[i]
        
    if(total > max):
        max = total

print(max)
