import kotlin.math.*

fun str() = readLine()!!
fun int() = str().toInt()
fun long() = str().toLong()

fun read(d:String = " ") = str().split(d)
fun <T> list(d:String = " ",f:String.()->T) = read(d).map {f(it)}
fun list() = list {toInt()}

fun <T> MutableList<T>.removeLast() = this.removeAt(this.lastIndex)

const val mod = 1000000007L

fun modpow(n:Long,p:Long = mod-2L):Long = when {
	p==0L->1L
	p%2==1L->n*modpow(n,p-1)%mod
	else-> {
		val d = modpow(n,p/2)
		d*d%mod
	}
}

fun main() {
	abc000X()
}

fun abc000X() {
	val n = long()
	val a = list {toLong()}

	val l = mutableListOf(1000L to 0L)

	for(i in a) {
		l.flatMap {(g,k)-> listOf(g%i to g/i+k,g+k*i to 0L)}
				.filter {a-> l.none {b-> a.first<=b.first&&a.second<=b.second}}
				.forEach {l.add(it)}
	}
	System.err.println(l.size)
	println(l.map {it.first}.max())
}
