fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val ax = readLine()!!.split(" ").map(String::toLong)
    fun gcd(a: Long, b: Long): Long {
        return if (b > 0) gcd(b, a % b) else a
    }

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

    val m = ax.reduce { acc, e -> lcm(acc, e) } - 1
    ax.fold(0L) { acc, e -> acc + (m % e) }.let(::println)

}
