#include <bits/stdc++.h>   using namespace std;   int N, S, M, K;   int A[2020], B[2020];   int L[2020], R[2020];   vector<int> V;   int MR[2020];   int dp[1600][1600];   int ok(int v) {     int i, j;     for (i = 0; i < (N); i++) B[i + 1] = B[i] + (A[i] <= v);     memset(dp, 0, sizeof(dp));     for (i = 0; i < (N); i++) {       for (j = 0; j < (M); j++) {         if (MR[i] > i) {           dp[MR[i]][j + 1] = max(dp[MR[i]][j + 1], dp[i][j] + B[MR[i]] - B[i]);           if (dp[MR[i]][j + 1] >= K) return 1;         }         dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);       }     }     return 0;   }   void solve() {     int i, j, k, l, r, x, y;     string s;     cin >> N >> S >> M >> K;     for (i = 0; i < (N); i++) {       cin >> A[i];       V.push_back(A[i]);     }     for (i = 0; i < (S); i++) {       cin >> L[i] >> R[i];       for (j = L[i] - 1; j < R[i]; j++) MR[j] = max(MR[j], R[i]);     }     sort((V.begin()), (V.end()));     V.erase(unique((V.begin()), (V.end())), V.end());     if (ok(V.back()) == 0) return (void)printf( -1 n );     int ret = V.size() - 1;     for (i = 12; i >= 0; i--) {       if (ret >= (1 << i) && ok(V[ret - (1 << i)])) ret -= 1 << i;     }     cout << V[ret] << endl;   }   int main(int argc, char** argv) {     string s;     int i;     if (argc == 1) ios::sync_with_stdio(false), cin.tie(0);     for (i = 0; i < (argc - 1); i++) s += argv[i + 1], s +=   n ;     for (i = 0; i < (s.size()); i++) ungetc(s[s.size() - 1 - i], stdin);     cout.tie(0);     solve();     return 0;   }   