Help me in solving AO19 problem

My issue

My code

# Update the code below to solve this problem

t = int(input())
for i in range(t):
    N, A, B = map(int, input().split())
    arr=list(map(int,input().split))
    p1=0
    p2=0
    for j in range(0,N-1):
        if arr[j]==A:
            p1+=1
        if arr[j]==B:
            p2+=1 
        i=i+1 
    a=float(( p1/ n)* (p2/ n))
    print(a)

Learning course: Solve Programming problems using Python
Problem Link: CodeChef: Practical coding for everyone