#include<bits/stdc++.h>
using namespace std;
const int N = 200043;
const int M = 200001;
typedef array<long long, 3> vec;
typedef array<vec, 3> mat;
vec operator+(const vec& a, const vec& b)
{
vec c;
for(int i = 0; i < 3; i++) c[i] = a[i] + b[i];
return c;
}
vec operator-(const vec& a, const vec& b)
{
vec c;
for(int i = 0; i < 3; i++) c[i] = a[i] - b[i];
return c;
}
vec operator*(const mat& a, const vec& b)
{
vec c;
for(int i = 0; i < 3; i++) c[i] = 0;
for(int i = 0; i < 3; i++)
for(int j = 0; j < 3; j++)
c[i] += a[i][j] * b[j];
return c;
}
mat operator*(const mat& a, const mat& b)
{
mat c;
for(int i = 0; i < 3; i++)
for(int j = 0; j < 3; j++)
c[i][j] = 0;
for(int i = 0; i < 3; i++)
for(int j = 0; j < 3; j++)
for(int k = 0; k < 3; k++)
c[i][k] += a[i][j] * b[j][k];
return c;
}
mat F = {vec({1, 0, 0}), vec({1, 1, 0}), vec({1, 2, 1})};
mat B = {vec({1, 0, 0}), vec({-1, 1, 0}), vec({1, -2, 1})};
mat E = {vec({1, 0, 0}), vec({0, 1, 0}), vec({0, 0, 1})};
vec S = {1, 0, 0};
vec Z = {0, 0, 0};
vec t[4 * N];
mat f[4 * N];
bool active[4 * N];
bool has[N];
int d, q;
vec getVal(int v)
{
if(!active[v]) return Z;
return f[v] * t[v];
}
void recalc(int v)
{
t[v] = getVal(v * 2 + 1) + getVal(v * 2 + 2);
}
void build(int v, int l, int r)
{
if(l == r - 1)
{
f[v] = E;
t[v] = S;
active[v] = false;
}
else
{
int m = (l + r) / 2;
build(v * 2 + 1, l, m);
build(v * 2 + 2, m, r);
f[v] = E;
recalc(v);
active[v] = true;
}
}
void push(int v)
{
if(f[v] == E) return;
t[v] = f[v] * t[v];
f[v * 2 + 1] = f[v] * f[v * 2 + 1];
f[v * 2 + 2] = f[v] * f[v * 2 + 2];
f[v] = E;
}
void updSegment(int v, int l, int r, int L, int R, bool adv)
{
if(L >= R) return;
if(l == L && r == R)
{
if(adv) f[v] = F * f[v];
else f[v] = B * f[v];
return;
}
push(v);
int m = (l + r) / 2;
updSegment(v * 2 + 1, l, m, L, min(m, R), adv);
updSegment(v * 2 + 2, m, r, max(m, L), R, adv);
recalc(v);
}
void setState(int v, int l, int r, int pos, bool val)
{
if(l == r - 1)
{
active[v] = val;
return;
}
push(v);
int m = (l + r) / 2;
if(pos < m)
setState(v * 2 + 1, l, m, pos, val);
else
setState(v * 2 + 2, m, r, pos, val);
recalc(v);
}
void addPoint(int x)
{
int lf = max(0, x - d);
int rg = x;
if(lf < rg)
updSegment(0, 0, M, lf, rg, true);
setState(0, 0, M, x, true);
}
void delPoint(int x)
{
int lf = max(0, x - d);
int rg = x;
if(lf < rg)
updSegment(0, 0, M, lf, rg, false);
setState(0, 0, M, x, false);
}
void query(int x)
{
if(has[x])
{
has[x] = false;
delPoint(x);
}
else
{
has[x] = true;
addPoint(x);
}
vec res = getVal(0);
printf("%lld\n", (res[2] - res[1]) / 2);
}
int main()
{
scanf("%d %d", &q, &d);
build(0, 0, M);
for(int i = 0; i < q; i++)
{
int x;
scanf("%d", &x);
query(x);
}
}