fun main(args : Array<String>) {
    val N = readLine()!!.toInt()
    val inputList = readLine()!!.split(" ").map { it.toInt() }

    // Order(N)
    fun objective(m: Int) : Int {
        return inputList.map { m.mod(it) }.sum()
    }

    val lcm = inputList.reduce { a, b -> lcm(a, b) }

    println(objective(lcm - 1))
}


fun gcd(a: Int, b: Int): Int {
    if (b == 0) return a
    return gcd(b, a % b)
}

fun lcm(a: Int, b: Int): Int {
    return a / gcd(a, b) * b
}