function main(input) {
    var arr = []
    var input = input.split("\n")
    input = input[1].split(" ")
  
    var max = 0
    for (var i = 1;;i++) {
        var current = 0
        for (var v in input) {
            current += i % Number(input[v])
        }
      	if(current === 0) {
          break
        }
      
        if (max < current) {
            max = current
        }
    }
  	console.log(max)
  }
  main(require('fs').readFileSync('/dev/stdin', 'utf8'));