def main():

    n = int(input())
    A = list(map(int, input().split()))

    dp = [[[0]*(10**2) for _ in range(10**4)] for _ in range(n+1)]
    dp[0][1000][0] = 1
    for i in range(n):
        for j in range(10**4):
            for k in range(10**2):
                if dp[i][j][k] != 0:
                    dp[i+1][j][k] = 1

        for j in range(10**4):
            for k in range(10**2):
                if dp[i][j][k] != 0:
                    dp[i+1][j+A[i]*k][0] = 1
        # buy
        for j in range(10**4):
            for k in range(10**2):
                if dp[i][j][k] != 0:
                    q, r = divmod(j, A[i])
                    dp[i+1][r][k+q] = 1

    for j in reversed(range(10**4)):
        for k in range(10**2):
            if dp[n][j][k] != 0:
                print(j)
                exit()

if __name__ == '__main__':
    main()
