Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
306 B
0
Indexable
Never
#include <iostream>
#include "windows.h"
#include <iostream>
using namespace std;
int foo(int mas[],int i) {
	if (mas[i] == 1) return i;
	return foo(mas, mas[i]);
}
int main() {
	int mas[1000];
	int a;
	cin >> a;
	for (int i = 0; i < a; i++){
		cin >> mas[i];
	}
	cout << foo(mas, 0);

}