def mode_max(N, arr):

    maximum = 0

    for i in range(1, 100001):

        current = 0

        for a in arr:

            current += i % a

        maximum = max(maximum, current)

    return maximum