using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var seqA = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();

        var max = Dfs(seqA, 1000, 0, n);

        Console.WriteLine(max);
    }

    private static long Dfs(Span<long> xs, long balance, long stock, int n)
    {
        if (xs.Length < 1)
        {
            return balance;
        }

        var b = Math.Max(balance, Dfs(xs.Slice(1), balance + stock * xs[0], 0, n));
        for (int i = 0; i < xs.Length; ++i)
        {
            var s = Math.DivRem(balance, xs[i], out var bi);
            b = Math.Max(b, Dfs(xs.Slice(i + 1), bi, stock + s, n));
        }

        return b;
    }
}
