import sys

import collections as c



input = sys.stdin.readline



def main():

    ans = 0

    n = int(eval(input()))

    d = list(map(int, input().split()))

    d.sort()

    g = d[n//2]

    items_count = c.Counter(d)

    gc = items_count[g]

    if gc == 1 or d[n//2-1] != g:

        ans += g - d[n//2-1]

    print(ans)



if __name__ == '__main__':

    main()
import sys



input = sys.stdin.readline



def main():

    ans = 0

    n = int(eval(input()))

    d = list(map(int, input().split()))

    d.sort()

    ans += d[n//2] - d[n//2-1]

    print(ans)



if __name__ == '__main__':

    main()
import sys
import collections as c

input = sys.stdin.readline


def main():
    ans = 0
    n = int(eval(input()))
    d = list(map(int, input().split()))
    d.sort()
    g = d[n // 2]
    items_count = c.Counter(d)
    gc = items_count[g]
    if gc == 1 or d[n // 2 - 1] != g:
        ans += g - d[n // 2 - 1]
    print(ans)


if __name__ == "__main__":
    main()

import sys

input = sys.stdin.readline


def main():
    ans = 0
    n = int(eval(input()))
    d = list(map(int, input().split()))
    d.sort()
    ans += d[n // 2] - d[n // 2 - 1]
    print(ans)


if __name__ == "__main__":
    main()

-import collections as c -    g = d[n // 2] -    items_count = c.Counter(d) -    gc = items_count[g] -    if gc == 1 or d[n // 2 - 1] != g: -        ans += g - d[n // 2 - 1] +    ans += d[n // 2] - d[n // 2 - 1]