require 'tsort'
class Hash
    include TSort
    alias tsort_each_node each_key
    def tsort_each_child(node, &block)
        fetch(node).each(&block)
    end
end
n = gets.to_i
h = {}
gets.split.map(&:to_i).each_with_index {|k , i| (h[i] ||= []) << (i + k) % n}
p h.strongly_connected_components.map(&:size).select {|x| x > 1}.inject(:+) + h.count {|k, a| a == [k]}

