def solve(n,p):
    
    memo = {}
    items = [(0,p)]
    result = 0
    while items:
        step, p = items.pop(0)
        if check(n,p):
            result = step
            break
        else:
            for i in range(n-1):
                candidate = tuple( p[:i] +[ p[i+1] ,p[i]] + p[i+2:] )
                if not candidate in memo:
                    items.append([step +1 , list(candidate)])
                    memo[candidate] = step + 1
                
    return result

if __name__ == '__main__':
    n = int(input())
    p = list(map(int, input().split(" ")))
    print(solve(n, p))
