'use strict'
function main(input) {
  input = input.split('\n')
  input = input[1].split(' ').sort((a, b) => Number(a) - Number(b))

  // 2個だったら最大にあわせる
  if (input.length === 2) {
    console.log(input[1])
    return
  }

  const sqrt = Math.floor(Math.sqrt(Math.max(...input)))
  let result = 0

  for (let i = 2; i <= sqrt; i++) {
    let zeroCount = 0
    let rMin = 999999
    input = input.map(val => {
      let r = 0
      let temp = val % i
      if (!val || temp) {
        zeroCount++
        return 0
      } else {
        do {
          r++
          val = val / i
        } while ((val % i) === 0)
        if (r < rMin) rMin = r
        return val
      }
    })
    if (zeroCount > 1) {
      break
    } else {
      result += i * rMin
    }
  }

  console.log(result) 
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
