#include<bits/stdc++.h>
using namespace std;
struct node{
long long x;
bool operator < (const node& dd) const {
return x < dd.x;
}
};
long long a[100050],n,k;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cin>>n>>k;
priority_queue<node>q;
for(int i = 1;i <= n;++i) cin>>a[i],q.push({a[i]});
for(int i = 1;i < n;++i){
int a1 = q.top().x; q.pop();
int a2 = q.top().x; q.pop();
q.push({(a1+a2)/k});
}
cout<<q.top().x;
return 0;
}