In a linear array, count the number of elements whose value coincides with their index.

To begin with, let’s get an empty array, which will then be sequentially filled with elements entered by the user from the keyboard, in the amount of N.

Then, using the for loop, we iterate over all the elements of the array and, thanks to the if condition, determine the number of elements whose values coincide with the index. Variable k is a counter of such elements.

N = int (input ())
a = []
k = 0
for i in range (N):
b = int (input ())
a.append (b)
for i in range (N):
if a [i] == i:
k + = 1
print (k)



One of the components of a person's success in our time is receiving modern high-quality education, mastering the knowledge, skills and abilities necessary for life in society. A person today needs to study almost all his life, mastering everything new and new, acquiring the necessary professional qualities.