// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on
void main()
{
    auto input = stdin.byLine.map!split.joiner;

    long N;
    N = input.front.to!long;
    input.popFront;

    long[] A = new long[](cast(size_t)(N));
    foreach (i; 0 .. cast(size_t)(N))
    {
        A[i] = input.front.to!long;
        input.popFront;
    }

    solve(N, A);
}

void solve(long N, long[] A)
{
    auto dp = new long[long][](N + 1);
    dp[0][1000] = 0;
    foreach (i; 0 .. N)
    {
        foreach (key, val; dp[i])
        {
            dp[i + 1][key] = dp[i + 1].get(key, 0).max(val);
            dp[i + 1][key % A[i]] = dp[i + 1].get(key % A[i], 0).max(val + key / A[i]);
            dp[i + 1][key + val * A[i]] = dp[i + 1].get(key + val * A[i], 0).max(0);
        }
    }
    writeln(dp[N].keys.reduce!max);
}
