#include <bits/stdc++.h>
using namespace std;

const int N = 2000;

int n, k, q;
int a[N + 1];

int main() {
    scanf("%d %d %d", &n, &k, &q);
    for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);

    sort(a + 1, a + n + 1);
    printf("%d\n", min(a[2] - a[1], a[n] - a[n - 1]);
}