#include <bits/stdc++.h>
using namespace std;
vector<int> d;
int n, a, b;
bool ok(int x) {
  int c = 0, locala = 0, localb = 0;
  for (int& i : d) {
    c++;
    if (i <= x) {
      localb = c;
      locala = n - localb;
    }
  }
  return locala == a && localb == b;
}
int main() {
  int t;
  cin >> n >> a >> b;
  for (int i = 0; i < n; i++) {
    cin >> t;
    d.push_back(t);
  }
  sort(d.begin(), d.end());
  int counter = 0;
  for (int i = 0; i < n; i++) {
    if (ok(d[i]) && i + 1 < n && ok(d[i + 1] - 1)) {
      counter += d[i + 1] - d[i];
    }
  }
  cout << counter;
  return 0;
}
