def examC():

    N = I(); A = [I() for _ in range(N)]

    AS = sorted(A)

    A0 = A[::2]

    d = defaultdict(bool)

    for i in AS[::2]:

        d[i] = True

    ans = 0

    for i in A0:

        if not d[i]:

            ans +=1

    print(ans)



import sys,copy,bisect,itertools,heapq,math

from heapq import heappop,heappush,heapify

from collections import Counter,defaultdict,deque

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

def LI(): return list(map(int,sys.stdin.readline().split()))

def LSI(): return list(map(str,sys.stdin.readline().split()))

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

def SI(): return sys.stdin.readline().strip()

mod = 10**9 + 7

inf = float('inf')



if __name__ == '__main__':

    examC()
def examA():

    S = SI()

    if "W" in S and not "E" in S:

        print("No")

    elif "E" in S and not "W" in S:

        print("No")

    elif "N" in S and not "S" in S:

        print("No")

    elif "S" in S and not "N" in S:

        print("No")

    else:

        print("Yes")

    return



def examB():

    N = I()

    A = [I()for _ in range(N)]

    ans = 0

    for i in range(N-1):

        ans += A[i]//2

        if A[i]%2 and A[i+1]>=1:

            ans += 1

            A[i+1] -= 1

    ans += A[N-1]//2

    print(ans)

    return



def examC():

    N = I()

    A = [I()for _ in range(N)]

    if N==1:

        print((0))

        return

    odd = set()

    for i in range(N):

        if i&1==0:

            odd.add(A[i])

    A.sort()

    ans = 0

    for i in range((N+1)//2):

        if A[i*2] in odd:

            continue

        ans += 1

    print(ans)

    return



def examD():

    N = I()

    S = [I()for _ in range(N)]



    ans = 0

    print(ans)

    return



def examE():

    ans = 0

    print(ans)

    return



def examF():

    ans = 0

    print(ans)

    return



import sys,bisect,itertools,heapq,math,random

from copy import deepcopy

from heapq import heappop,heappush,heapify

from collections import Counter,defaultdict,deque

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

def LI(): return list(map(int,sys.stdin.readline().split()))

def LSI(): return list(map(str,sys.stdin.readline().split()))

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

def SI(): return sys.stdin.readline().strip()

global mod,mod2,inf,alphabet,_ep

mod = 10**9 + 7

mod2 = 998244353

inf = 10**18

_ep = 10**(-12)

alphabet = [chr(ord('a') + i) for i in range(26)]



sys.setrecursionlimit(10**6)



if __name__ == '__main__':

    examC()



"""



"""
def examC():
    N = I()
    A = [I() for _ in range(N)]
    AS = sorted(A)
    A0 = A[::2]
    d = defaultdict(bool)
    for i in AS[::2]:
        d[i] = True
    ans = 0
    for i in A0:
        if not d[i]:
            ans += 1
    print(ans)


import sys, copy, bisect, itertools, heapq, math
from heapq import heappop, heappush, heapify
from collections import Counter, defaultdict, deque


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


def LI():
    return list(map(int, sys.stdin.readline().split()))


def LSI():
    return list(map(str, sys.stdin.readline().split()))


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


def SI():
    return sys.stdin.readline().strip()


mod = 10**9 + 7
inf = float("inf")
if __name__ == "__main__":
    examC()

def examA():
    S = SI()
    if "W" in S and not "E" in S:
        print("No")
    elif "E" in S and not "W" in S:
        print("No")
    elif "N" in S and not "S" in S:
        print("No")
    elif "S" in S and not "N" in S:
        print("No")
    else:
        print("Yes")
    return


def examB():
    N = I()
    A = [I() for _ in range(N)]
    ans = 0
    for i in range(N - 1):
        ans += A[i] // 2
        if A[i] % 2 and A[i + 1] >= 1:
            ans += 1
            A[i + 1] -= 1
    ans += A[N - 1] // 2
    print(ans)
    return


def examC():
    N = I()
    A = [I() for _ in range(N)]
    if N == 1:
        print((0))
        return
    odd = set()
    for i in range(N):
        if i & 1 == 0:
            odd.add(A[i])
    A.sort()
    ans = 0
    for i in range((N + 1) // 2):
        if A[i * 2] in odd:
            continue
        ans += 1
    print(ans)
    return


def examD():
    N = I()
    S = [I() for _ in range(N)]
    ans = 0
    print(ans)
    return


def examE():
    ans = 0
    print(ans)
    return


def examF():
    ans = 0
    print(ans)
    return


import sys, bisect, itertools, heapq, math, random
from copy import deepcopy
from heapq import heappop, heappush, heapify
from collections import Counter, defaultdict, deque


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


def LI():
    return list(map(int, sys.stdin.readline().split()))


def LSI():
    return list(map(str, sys.stdin.readline().split()))


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


def SI():
    return sys.stdin.readline().strip()


global mod, mod2, inf, alphabet, _ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10 ** (-12)
alphabet = [chr(ord("a") + i) for i in range(26)]
sys.setrecursionlimit(10**6)
if __name__ == "__main__":
    examC()
"""
"""

+def examA(): +    S = SI() +    if "W" in S and not "E" in S: +        print("No") +    elif "E" in S and not "W" in S: +        print("No") +    elif "N" in S and not "S" in S: +        print("No") +    elif "S" in S and not "N" in S: +        print("No") +    else: +        print("Yes") +    return + + +def examB(): +    N = I() +    A = [I() for _ in range(N)] +    ans = 0 +    for i in range(N - 1): +        ans += A[i] // 2 +        if A[i] % 2 and A[i + 1] >= 1: +            ans += 1 +            A[i + 1] -= 1 +    ans += A[N - 1] // 2 +    print(ans) +    return + + -    AS = sorted(A) -    A0 = A[::2] -    d = defaultdict(bool) -    for i in AS[::2]: -        d[i] = True +    if N == 1: +        print((0)) +        return +    odd = set() +    for i in range(N): +        if i & 1 == 0: +            odd.add(A[i]) +    A.sort() -    for i in A0: -        if not d[i]: -            ans += 1 +    for i in range((N + 1) // 2): +        if A[i * 2] in odd: +            continue +        ans += 1 +    return -import sys, copy, bisect, itertools, heapq, math +def examD(): +    N = I() +    S = [I() for _ in range(N)] +    ans = 0 +    print(ans) +    return + + +def examE(): +    ans = 0 +    print(ans) +    return + + +def examF(): +    ans = 0 +    print(ans) +    return + + +import sys, bisect, itertools, heapq, math, random +from copy import deepcopy +global mod, mod2, inf, alphabet, _ep -inf = float("inf") +mod2 = 998244353 +inf = 10**18 +_ep = 10 ** (-12) +alphabet = [chr(ord("a") + i) for i in range(26)] +sys.setrecursionlimit(10**6) +""" +"""