import sys


def _i(): return int(sys.stdin.readline().strip())


def _ia(): return map(int, sys.stdin.readline().strip().split())


def main():
    n = _i()
    a = list(_ia())

    for i in range(1, n):
        if a[i]-a[i-1] > 0:
            j = i - 1
            break
    else:
        return 1000

    pairs = []
    m = a[j]
    flag = True
    for i in range(j, n-1):
        if flag and a[i+1] - a[i] < 0:
            pairs.append([m, a[i]])
            flag = False
        elif (not flag) and a[i+1] - a[i] > 0:
            m = a[i]
            flag = True
    if flag:
        pairs.append([m, a[-1]])

    w = {0: 1000}
    for p in pairs:
        low, hi = p
        tmp = {}
        for c, val in w.items():
            for a, v in enumerate(range(0, val+1, low)):
                cnt = c + a
                tmp[cnt] = max(tmp.get(cnt, 0), val - v)

        for c, val in tmp.items():
            for a in range(0, c+1):
                cnt = c - a
                w[cnt] = max(tmp.get(cnt, 0), val + a * hi)

    return max(w.values())


if __name__ == "__main__":
    print(main())
