#include using namespace std; typedef long long ll; #define i_7 (ll)(1E9+7) #define i_5 (ll)(1E9+5) ll mod(ll a){ ll c=a%i_7; if(c>=0)return c; else return c+i_7; } typedef pair i_i; typedef pair l_l; ll inf=(ll)1E12; #define rep(i,l,r) for(ll i=l;i<=r;i++) #define pb push_back ll max(ll a,ll b){if(ab)return b;else return a;} void Max(ll * pos,ll val){*pos=max(*pos,val);}//Max(&dp[i][j],dp[i-1][j]); void Min(ll * pos,ll val){*pos=min(*pos,val);} void Add(ll * pos,ll val){*pos=mod(*pos+val);} const long double EPS=1E-8; //////////////////////////////////////// ll n,k; #define N (ll)1E6+5 ll gru[N]; ll grundy(ll p){ if(gru[p]!=-1)return gru[p]; sets; rep(i,1,k){ if(p-i<0)break; s.insert(grundy(p-i)); } ll pos=0; while(1){ if(s.find(pos)!=s.end())pos++; else return gru[p]=pos; } } int main(){ cin>>n>>k; ll a[n];rep(i,0,n-1)cin>>a[i]; fill(gru,gru+N,-1); ll g[n]; //rep(i,0,100000)cout<