#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define input(n,arr) int n;cin>>n;int arr[n];for(int i=0;i<n;i++)cin>>arr[i];
#define inputl(n,arr) int n;cin>>n;ll arr[n];for(int i=0;i<n;i++)cin>>arr[i];
#define rep(i,n) for(int i=0;i<n;i++)
#define repi(i,l,n) for(int i=l;i<n;i++)
#define all(c) c.begin(),c.end()
#define BSDK ios_base::sync_with_stdio(false);cin.tie(NULL);
#define out(arr) for(auto i:arr)cout<<i<<" ";cout<<"\n";
#define cout(a) cout<<a<<"\n"
#define cout2(a,b) cout<<a<<" "<<b<<"\n"
#define cout3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define N 1000000007

void solve(){
  ll n,x,temp,ans,k;
    cin>>n>>x;
    ll arr[x]={0};
    ll mn=0;
    k=0;
    set<pll> s;
    for(ll i=0;i<x;i++)s.insert({k,i});

    for(int i=0;i<n;i++){
        cin>>temp;
        arr[temp%x]++;
        s.erase(s.find({arr[temp%x]-1,temp%x}));
        s.insert({arr[temp%x],temp%x});
        k=s.begin()->second;
        ans=arr[k]*x+k;
        cout<<"ans="<<ans<<endl;
    }
}


int main(){
 // BSDK
int t;
t=1;
 // cin>>t;
while(t--)solve();
return 0;
}
