/* Copyright (C) 2009 Igor V. Burago */

#include <cassert>
#include <fstream>
#include <vector>
#include <string>
#include <iterator>
#include <algorithm>
#include <limits>

using namespace std;


typedef int Data;
typedef bool (*CompareFunction)(Data, Data);

bool compareLess(Data x, Data y) { return x < y; }
bool compareGreater(Data x, Data y) { return y < x; }


int main()
{
    ifstream input("input.txt");
    ofstream output("output.txt");

    int commandsCount;
    input >> commandsCount;
    assert(1 <= commandsCount && commandsCount <= 500000);

    Data median = numeric_limits<Data>::min();
    vector<Data> dataset[2];
    CompareFunction compare[2] = { compareLess, compareGreater };

    for (int command = 0; command < commandsCount; ++command)
    {
        Data value;
        assert(input >> value);
        assert(abs(value) <= 1000000000);

        vector<Data> &heap = dataset[median <= value];
        heap.push_back(value);
        push_heap(heap.begin(), heap.end(), compare[median <= value]);

        const int skew = static_cast<int>(dataset[0].size()) - dataset[1].size();
        const int skewIndex = (skew < 0);
        if (1 < abs(skew))
        {
            vector<Data> &heapFrom = dataset[skewIndex];
            vector<Data> &heapTo = dataset[1 - skewIndex];
            heapTo.push_back(heapFrom.front());
            pop_heap(heapFrom.begin(), heapFrom.end(), compare[skewIndex]);
            heapFrom.pop_back();
            push_heap(heapTo.begin(), heapTo.end(), compare[1 - skewIndex]);
        }
        median = dataset[dataset[0].size() < dataset[1].size()].front();

        /*
        copy(dataset[0].begin(), dataset[0].end(), ostream_iterator<Data>(output, " "));
        output << "| ";
        copy(dataset[1].begin(), dataset[1].end(), ostream_iterator<Data>(output, " "));
        output << endl;
        */
        output << median << endl;
    }

    return 0;
}
