#include <bits/stdc++.h>
using namespace std;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
vector<int> G[100005];
std::vector<pair<long long, long long> > tree[100010];
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};
long long i, j, k, l, ii, jj;
long long n, m, q;
long long a[300005], b[300005];
long long x, y, look, ans = 0, num;
bool flag;
char s[300005];
long long e, w, ee, ww;
int main() {
  cin >> n >> k >> q;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  cout << a[q - 1] - a[0] << endl;
  ;
}
