Help me in solving CRITLIST problem

My issue

the code is executed properly in other compiler but while submitting in code chef it showing error at n=int(input()) at tthis lline the error was reading
Traceback (most recent call last):
File “/mnt/sol.py”, line 36, in
n = int(input())
^^^^^^^
EOFError: EOF when reading a line

My code

class Node:
    def __init__(self, val):
         self.val = val
         self.next = None
def solve(head):
    p=head.next
    count=0
    while p.next.next is not None:
        if(p.next.val<p.val and p.next.val<p.next.next.val or p.next.val >p.val and p.next.val>p.next.next.val):
            count+=1
        p=p.next
    return count
def linked(a):
    head=Node(a[0])
    l=head
    for i in range(0,len(a)):
        l.next=Node(a[i])
        l=l.next
    return head



if __name__ == '__main__':
    n=int(input())
    a=list(map(int,input().split()))
    head=linked(a)
    print(solve(head))


Learning course: Linked Lists
Problem Link: CodeChef: Practical coding for everyone