Help me in solving PUSH7PA problem

My issue

My code

t=int(input())
for i in range(t):
    n=int(input())
    a=list(map(int,input().strip().split()))[:n]
    sum=a[0]
    for i in range(1,n):
        if a[i]-1==a[i-1]:
            sum+=a[i]
    print(sum)    

Problem Link: CodeChef: Practical coding for everyone

@anuroopgowda12
Your logic is not right
the logic is count the freq of each number then take the max of all (value+ freq(value)-1);
like ex 1 2 1 3
the freq of 1 is 2
the freq of 2 is 1;
and freq of 3 is 1;
now take max of 1+2-1,2+1-1,3+1-1 which will give u 3 as answer.