# -*- encoding: utf-8 -*-
import sys
r_input = sys.stdin.readline


def run():
    q, x = map(int, r_input().split())

    result = 0

    pass_list = [0] * 1000000

    for _ in range(q):
        num = int(r_input())

        if num == result:
            result += 1

        else:
            if num < result:
                tmp = result - num
                num += x * (tmp // x)

                if num == result:
                    result += 1
                else:
                    pass_list[num + x] = 1

            else:
                tmp = num - result
                num -= x * (tmp // x)

                if num == result:
                    result += 1

                else:
                    pass_list[num] = 1

        while pass_list[result]:
            result += 1

        print(result)


if __name__ == '__main__':
    run()
