# coding:utf-8



INF = float('inf')





def inpl(): return list(map(int, input().split()))





N = int(eval(input()))

A = [int(eval(input())) for _ in range(N)]

B = sorted(A)

C = A[::2] + B[1::2]

D = set(C)



print((N - len(D)))
# coding:utf-8



import sys



INF = float('inf')

MOD = 10 ** 9 + 7



def LI(): return [int(x) for x in sys.stdin.readline().split()]

def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF(): return [float(x) for x in sys.stdin.readline().split()]

def LS(): return sys.stdin.readline().split()

def II(): return int(sys.stdin.readline())

def SI(): return eval(input())





def main():

    n = II()

    A = [II() for _ in range(n)]



    B = A[:]

    A.sort()



    return (n + 1) // 2 - len(set(A[::2]) & set(B[::2]))





print((main()))

# coding:utf-8
INF = float("inf")


def inpl():
    return list(map(int, input().split()))


N = int(eval(input()))
A = [int(eval(input())) for _ in range(N)]
B = sorted(A)
C = A[::2] + B[1::2]
D = set(C)
print((N - len(D)))

# coding:utf-8
import sys

INF = float("inf")
MOD = 10**9 + 7


def LI():
    return [int(x) for x in sys.stdin.readline().split()]


def LI_():
    return [int(x) - 1 for x in sys.stdin.readline().split()]


def LF():
    return [float(x) for x in sys.stdin.readline().split()]


def LS():
    return sys.stdin.readline().split()


def II():
    return int(sys.stdin.readline())


def SI():
    return eval(input())


def main():
    n = II()
    A = [II() for _ in range(n)]
    B = A[:]
    A.sort()
    return (n + 1) // 2 - len(set(A[::2]) & set(B[::2]))


print((main()))

+import sys + +MOD = 10**9 + 7 -def inpl(): -    return list(map(int, input().split())) +def LI(): +    return [int(x) for x in sys.stdin.readline().split()] -N = int(eval(input())) -A = [int(eval(input())) for _ in range(N)] -B = sorted(A) -C = A[::2] + B[1::2] -D = set(C) -print((N - len(D))) +def LI_(): +    return [int(x) - 1 for x in sys.stdin.readline().split()] + + +def LF(): +    return [float(x) for x in sys.stdin.readline().split()] + + +def LS(): +    return sys.stdin.readline().split() + + +def II(): +    return int(sys.stdin.readline()) + + +def SI(): +    return eval(input()) + + +def main(): +    n = II() +    A = [II() for _ in range(n)] +    B = A[:] +    A.sort() +    return (n + 1) // 2 - len(set(A[::2]) & set(B[::2])) + + +print((main()))