#!python3

# input
N, K, Q = list(map(int, input().split()))
A = list(map(int, input().split()))


def main():
    w = sorted(A)
    ans = w[Q-1] - w[0]
    print(ans)


if __name__ == "__main__":
    main()
