fun main(args:Array<String>?): Unit {
    val n = readLine()!!.toInt()
    val cells = readLine()!!.trim().split(' ').map(String::toInt)
    val memo = Array(n){null as Boolean?}
    for (i in cells.indices){
        var single = i
        var double = (i + cells[i]) % n
        while(single != double && memo[double] == null){
            single = (single + cells[single]) % n
            double = (double + cells[double]) % n
            double = (double + cells[double]) % n
        }
        if (memo[double] == null){
            memo[single] = true
            single = (single + cells[single]) % n
            while(single != double){
                memo[single] = true
                single = (single + cells[single]) % n
            }
        }
        single = i
        while (memo[single] == null){
            memo[single] = false
            single = (single + cells[single]) % n
        }
    }
    println(
            memo.count{it!!}
    )
}
