Buggy python submission (verdict: Runtime Error):
n = int(input())
alist = [int(input())-1 for _ in range(n)]

now = 0
count = 0
while True:
    if now == 1:
        print(count)
        break
    elif c >= n:
        print(-1)
        break
    else:
        count += 1
        now = alist[now]

Fixed submission:
n = int(input())
alist = [int(input())-1 for _ in range(n)]

now = 0
count = 0
while True:
    if now == 1:
        print(count)
        break
    elif count >= n:
        print(-1)
        break
    else:
        count += 1
        now = alist[now]

Buggy python submission (verdict: Runtime Error):
n = int(input())
alist = [int(input())-1 for _ in range(n)]

now = 0
count = 0
while True:
    if now == 1:
        print(coount)
        break
    elif c >= n:
        print(-1)
        break
    else:
        count += 1
        now = alist[now]


Fixed submission:
n = int(input())
alist = [int(input())-1 for _ in range(n)]

now = 0
count = 0
while True:
    if now == 1:
        print(count)
        break
    elif count >= n:
        print(-1)
        break
    else:
        count += 1
        now = alist[now]

Buggy python submission (verdict: Runtime Error):
n = int(input())
alist = [int(input())-1 for _ in range(n)]

now = 0
count = 0
while True:
    if now == 1:
        print(c)
        break
    elif c >= n:
        print(-1)
        break
    else:
        count += 1
        now = alist[now]

Fixed submission:
n = int(input())
alist = [int(input())-1 for _ in range(n)]

now = 0
count = 0
while True:
    if now == 1:
        print(count)
        break
    elif count >= n:
        print(-1)
        break
    else:
        count += 1
        now = alist[now]

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
alist = [int(input())-1 for _ in range(n)]

visitedlist = [0]
from_ = 0
for _ in range(n):
    to = alist[from_]
    if to in visitedlist:
        print(-1)
        break
    elif to == 1:
        print(len(visitedlist))
        break
    else:
        visitedlist.append(to)
        from_ = to

Fixed submission:
n = int(input())
alist = [int(input())-1 for _ in range(n)]

now = 0
count = 0
while True:
    if now == 1:
        print(count)
        break
    elif count >= n:
        print(-1)
        break
    else:
        count += 1
        now = alist[now]

Buggy python submission (verdict: Runtime Error):
n = int(input())
alist = [int(input())-1 for _ in range(n)]

visitedlist = [0]
from = 0
for _ in range(n):
    to = alist[from]
    if to in visitedlist:
        print(-1)
        break
    elif to == 1:
        print(len(visitedlist))
        break
    else:
        visitedlist.append(to)
        from = to


Fixed submission:
n = int(input())
alist = [int(input())-1 for _ in range(n)]

now = 0
count = 0
while True:
    if now == 1:
        print(count)
        break
    elif count >= n:
        print(-1)
        break
    else:
        count += 1
        now = alist[now]

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
alist = [int(input())-1 for _ in range(n)]

visitedlist = [0]
from_ = 0
while True:
    to = alist[from_]
    if to in visitedlist:
        print(-1)
        break
    elif to == 1:
        print(len(visitedlist))
        break
    else:
        visitedlist.append(to)
        from_ = to

Fixed submission:
n = int(input())
alist = [int(input())-1 for _ in range(n)]

now = 0
count = 0
while True:
    if now == 1:
        print(count)
        break
    elif count >= n:
        print(-1)
        break
    else:
        count += 1
        now = alist[now]