//Program: zabava
//Author: gary
//Date: 18/10/2014
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;
#define SZ(x) ( (int) (x).size() )
#define dbg(x) cerr << #x << " = " << x << endl;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> pii;
// const int INF = 1e9;
// const int MAX_N = ;
ll g(int x) { return 1LL * x * (x + 1) / 2; }
// n students, m groups
ll func(int n, int m){
int a = n / m;
int b = n % m;
return b * g(a + 1) + (m - b) * g(a);
}
const int MAX_M = 100 + 5;
const int MAX_K = 500 + 5;
int N, M, K;
int C[MAX_M];
ll D[MAX_M][MAX_K];
void mmin(ll& a, ll b){
a = min(a, b);
}
int main(){
int x;
scanf("%d%d%d", &N, &M, &K);
for(int i = 0; i < N; i++){
scanf("%d", &x);
C[x] ++;
}
for(int i = 1; i <= M; i++){
for(int j = K; j >= 0; j--){
D[i][j] = (1LL << 62);
for(int k = 0; j + k <= K; k++){
mmin(D[i][j], D[i - 1][j + k] + func(C[i], k + 1));
}
}
}
printf("%lld\n", D[M][0]);
return 0;
}
Ly9Qcm9ncmFtOiB6YWJhdmEKLy9BdXRob3I6IGdhcnkKLy9EYXRlOiAxOC8xMC8yMDE0CiNpbmNsdWRlIDxjc3RkaW8+CiNpbmNsdWRlIDxjc3RyaW5nPgojaW5jbHVkZSA8Y21hdGg+CiNpbmNsdWRlIDxpb3N0cmVhbT4KI2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPHNldD4KI2luY2x1ZGUgPG1hcD4KI2luY2x1ZGUgPHF1ZXVlPgojaW5jbHVkZSA8c3RhY2s+CiNpbmNsdWRlIDxzdHJpbmc+CiNpbmNsdWRlIDxhbGdvcml0aG0+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgU1ooeCkgKCAoaW50KSAoeCkuc2l6ZSgpICkKI2RlZm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