n = gets.to_i
sugoroku = gets.split.map(&:to_i)


visit_count_list = Array.new(n) { 0 }
index = 0
count = 0

while visit_count_list[index] < 2
  count += 1
  visit_count_list[index] += 1

  index = (index + sugoroku[index]) % n
end

puts visit_count_list.count { |i| i > 1 }