// tresc: https://szkopul.edu.pl/problemset/problem/8-Z3rWfeUiuDVT7E9Yc3LTFt/site/?key=statement
// OIG II (2 etap)
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
int main() {
std::ios_base::sync_with_stdio(0);
std::cin.tie(0);
std::cout.tie(0);
int n;
long long k;
std::cin >> n >> k;
std::vector<long long> v;
for (int i = 0; i < n; i++) {
long long a;
std::cin >> a;
if (a % k == 0) {
v.push_back(a / k);
}
}
long long ans = k;
std::sort(v.begin(), v.end());
bool flag = true;
for (int i = 0; i < v.size(); i++) {
if (v[i] != i + 1) {
ans = k * (i + 1);
flag = false;
break;
}
}
if (flag) {
ans = k * (v[v.size() - 1] + 1);
}
std::cout << ans << '\n';
return 0;
}