#include <bits/stdc++.h>
using namespace std;
struct KSet
{
int k;
multiset<int> S, L;
long long sm = 0;
KSet(int _k) : k(_k) {}
void rebalance()
{
while ((int)S.size() > k)
{
int x = *S.rbegin();
S.erase(prev(S.end()));
sm -= x;
L.insert(x);
}
while ((int)S.size() < k && !L.empty())
{
int x = *L.begin();
L.erase(L.begin());
sm += x;
S.insert(x);
}
}
void add(int x)
{
if (!S.empty() && x > *S.rbegin())
L.insert(x);
else
{
S.insert(x);
sm += x;
}
rebalance();
}
void rem(int x)
{
auto it = S.find(x);
if (it != S.end())
{
sm -= x;
S.erase(it);
}
else
{
auto it2 = L.find(x);
assert(it2 != L.end());
L.erase(it2);
}
rebalance();
}
};
int main()
{
int n, m, k;
cin >> n >> m >> k;
vector<int> ar(n);
for (int i = 0; i < n; ++i)
cin >> ar[i];
vector<int> ord(n);
iota(ord.begin(), ord.end(), 0);
sort(ord.begin(), ord.end(), [&](int i, int j) -> bool
{
return ar[i] < ar[j];
});
vector<bool> good(n, false);
for (int i = 0; i < m; ++i)
good[ord[i]] = true;
long long sm = 0;
KSet in(k), out(k);
for (int i = 0; i < m; ++i)
{
sm += ar[i];
if (!good[i])
in.add(-ar[i]);
}
for (int i = m; i < n; ++i)
{
if (good[i])
out.add(ar[i]);
}
long long ans = sm + in.sm + out.sm;
for (int i = 0; i + m < n; ++i)
{
sm -= ar[i];
if (good[i])
out.add(ar[i]);
else
in.rem(-ar[i]);
sm += ar[i + m];
if (good[i + m])
out.rem(ar[i + m]);
else
in.add(-ar[i + m]);
long long cost = sm + in.sm + out.sm;
ans = min(ans, cost);
}
cout << ans << '\n';
return 0;
}