require 'set'
n = gets.to_i
g = {}
g_inv = {}
gets.split.map(&:to_i).each_with_index do |k , i|
    j = (i + k) % n
    g[i] = j
    (g_inv[j] ||= Set.new) << i
end
queue = (0..n-1).select {|i| !g_inv[i]}
until queue.empty?
    n -= 1
    i = queue.shift
    j = g[i]
    g_inv[j].delete(i)
    if g_inv[j].empty?
        queue << j
    end
end
p n
