def solve(a, n):
    count1 = 0  # inversions where a[i] > a[j] (i < j)
    count2 = 0  # inversions where a[i] < a[j] (i < j) -- actually let's think about this
    
    # Type 1: count of pairs (i,j) where i < j and a[i] > a[j]
    # Type 2: count of pairs (i,j) where i < j and a[i] < a[j]
    
    for i in range(n):
        for j in range(i+1, n):
            if a[i] > a[j]:
                count1 += 1
            elif a[i] < a[j]:
                count2 += 1
    
    return count1 == count2