#include <bits/stdc++.h>
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
using namespace std;
using ll = long long;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }
int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
  ll N, K, Q;
  cin >> N >> K >> Q;
  priority_queue<ll, vector<ll>, greater<ll>> pq;
  for (ll i = 0; i < (N); ++i) {
    ll a;
    cin >> a;
    pq.push(a);
  }
  ll ans = 0;
  for (ll i = 0; i < (Q); ++i) {
    ll now = pq.top();
    pq.pop();
    if (i == 0) ans -= now;
    if (i == Q - 1) ans += now;
  }
  cout << (ans) << '\n';
  return 0;
}
