#include <bits/stdc++.h>
using namespace std;
int main() {
int n, x;
cin >> n >> x;
vector<long long> A(n); // Using long long to handle large numbers
long long original_sum = 0;
for (int i = 0; i < n; i++) {
cin >> A[i];
original_sum += A[i];
}
long long min_sum = original_sum;
for (int i = 0; i < n; i++) {
long long transformed_value = A[i];
while (transformed_value % x == 0) {
transformed_value /= x;
}
transformed_value *= x;
long long current_sum = original_sum - A[i] + transformed_value;
min_sum = min(min_sum, current_sum);
}
cout << min_sum << endl;
return 0;
}
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,x;
cin>>n>>x;
vector<long long> v(n);
long long origsum=0;
for(int i=0;i<n;i++){ cin>>v[i]; origsum+=v[i];}
long long minsum=origsum;
for(int i=0;i<n;i++)
{
long long val=v[i];
if(val%x==0) continue;
while(val%x!=0)
val= (val/x)*x;
minsum-=v[i];
minsum+=val;
}
return minsum;
}