class MinHeap:
    class Node:
        def __init__(self, i, key, priority):
            self.i = i
            self.key = key
            self.priority = priority
        
        def __repr__(self):
            return "Node[i:{} k:{} p:{}]".format(
                    self.i, self.key, self.priority)
    
    def sift_up(self, i):
        while i > 0:
            p = (i - 1) // 2
            if self.heap[i].priority < self.heap[p].priority:
                self.heap[i].i, self.heap[p].i = p, i
                self.heap[i], self.heap[p] = self.heap[p], self.heap[i]
                i = p
            else:
                break
    
    def sift_down(self, i):
        while 2 * i + 1 < len(self.heap):
            m = i
            l = 2 * i + 1
            if self.heap[l].priority < self.heap[m].priority:
                m = l
            r = l + 1
            if (    r < len(self.heap)
                and self.heap[r].priority < self.heap[m].priority):
                m = r
            if m != i:
                self.heap[i].i, self.heap[m].i = m, i
                self.heap[i], self.heap[m] = self.heap[m], self.heap[i]
                i = m
            else:
                break
    
    def lowest_priority(self):
        return self.heap[0].priority
    
    def lowest_priority_key(self):
        return self.heap[0].key
    
    def get_priority(self, key):
        return self.mapping[key].priority
    
    def set_priority(self, key, new_priority):
        node = self.mapping[key]
        if new_priority < node.priority:
            node.priority = new_priority
            self.sift_up(node.i)
        elif new_priority > node.priority:
            node.priority = new_priority
            self.sift_down(node.i)
    
    def add_priority(self, key, priority):
        node = self.Node(len(self.heap), key, priority)
        self.mapping[key] = node
        self.heap.append(node)
        self.sift_up(len(self.heap) - 1)
    
    def remove_priority(self, key):
        node = self.mapping[key]
        if node.i < len(self.heap) - 1:
            replacement_node = self.heap.pop()
            self.heap[node.i] = replacement_node
            replacement_node.i = node.i
            if replacement_node.priority < node.priority:
                self.sift_up(node.i)
            elif replacement_node.priority > node.priority:
                self.sift_down(node.i)
        else:
            self.heap.pop()
        del self.mapping[key]
    
    def __init__(self, priorities={}):
        if priorities is not None:
            self.mapping = {}
            self.heap = []
            for key, priority in priorities.items():
                node = self.Node(len(self.heap), key, priority)
                self.mapping[key] = node
                self.heap.append(node)
        for i in range(len(self.heap) - 1, -1, -1):
                self.sift_up(i)
    
    def __len__(self):
        return len(self.heap)
    
    def __repr__(self):
        return repr(self.heap)


import sys

q, x = (int(v) for v in sys.stdin.readline().split())
H = MinHeap({m: (0, m) for m in range(x)})

for i in range(q):
    n = int(sys.stdin.readline())
    m = n % x
    mis_n, mis_m = H.get_priority(m)
    H.set_priority(m, (mis_n + 1, mis_m))
    mis_n, mis_m = H.lowest_priority()
    print(mis_n * x + mis_m)
