import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;


struct FenwickTree(T) {
    private {
        int _size;
        T[] _data;
    }

    this(int N) {
        _size = N;
        _data = new T[](_size + 1);
    }

    void add(int i, T x) {
        i++;
        while (i <= _size) {
            _data[i] += x;
            i += i & (-i);
        }
    }

    T sum(int r) {
        T res = 0;
        while (r > 0) {
            res += _data[r];
            r -= r & (-r);
        }
        return res;
    }
}

unittest {
    auto ft = FenwickTree!(int)(10);
    ft.add(0, 3);
    ft.add(2, 4);
    ft.add(5, 1);
    assert(ft.sum(0) == 0);
    assert(ft.sum(1) == 3);
    assert(ft.sum(2) == 3);
    assert(ft.sum(3) == 7);
    assert(ft.sum(5) == 7);
    assert(ft.sum(6) == 8);
}



void main() {
    int N;
    scan(N);
    auto a = readln.split.to!(int[]);
    auto as = a.dup.sort();

    bool check(int x) {
        auto b = a.map!(ai => ai <= x ? 1 : 0).array;
        auto s = new int[](N + 1);
        foreach (i ; 1 .. N + 1) {
            s[i] = s[i - 1] + b[i - 1];
        }
        auto ft = FenwickTree!(int)(3*N + 1);
        long cnt;
        foreach (i ; 0 .. N + 1) {
            int p = 2 * s[i] - i + N;
            cnt += ft.sum(p);
            ft.add(p, 1);
        }
        debug {
            writefln("cnt: %s", cnt);
        }
        return 2L * cnt > 1L * N * (N + 1) / 2;
    }

    int ng = -1, ok = N;
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        int x = as[mid];
        (check(x) ? ok : ng) = mid;
    }

    auto ans = as[ok];
    writeln(ans);
}



void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}
