#include <iostream>
#include <vector>
#include <algorithm>

int main() {
    int n, k;
    std::cin >> n >> k;

    std::vector<int> rocks(n);
    for (int i = 0; i < n; ++i) {
        std::cin >> rocks[i];
    }

    // Resultant array which will contain the rocks in the smallest lexicographical order
    std::vector<int> result;

    // We need to sort segments where the weight difference is less than or equal to `k`
    int start = 0;

    while (start < n) {
        int end = start;

        // Find the segment which can be sorted (based on the weight difference condition)
        while (end < n - 1 && std::abs(rocks[end + 1] - rocks[end]) <= k) {
            end++;
        }

        // Create a subvector for this segment and sort it
        std::vector<int> segment(rocks.begin() + start, rocks.begin() + end + 1);
        std::sort(segment.begin(), segment.end());

        // Append the sorted segment to the result
        result.insert(result.end(), segment.begin(), segment.end());

        // Move to the next segment
        start = end + 1;
    }

    // Output the result, which should be the smallest lexicographical sequence
    for (int val : result) {
        std::cout << val << "\n";
    }

    return 0;
}
