Help me in solving MAXDISTPERM problem

My issue

i took array and make A= sorted array of n and then remove n from A and inserted it at index 0

My code

t= int(input())

i=1 
while i<=t:
    n=int(input())
    A=[]
    for j in range(1,n+1):
        A.insert(j-1,j)
    for a in range(len(A)):
        print(A[a], end=' ')
    print("\n",end='')
    A.remove(n)
    A.insert(0,n)
    B=A
    for b in range(len(B)):
        print(B[b], end=' ')
    print("\n", end='')
    i=i+1

Problem Link: Maximum Distance Permutations Practice Coding Problem

no you are doing it wrong
the way which you are solving the problem will give distance 1
but that distance can’t be maximum in all case
testcase
4
here maximum distance possible is 2
1 2 3 4
3 4 1 2