#!python
# -*- coding: utf-8 -*-


def main():
    N, K, Q = map(int, input().split())
    A = list(map(int, input().split()))

    A.sort()
    print(A[Q - 1] - A[0])


if __name__ == '__main__':
    main()
