#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cassert>

using namespace std;

typedef long long i64;

const int MAXN = 200000;

int a[MAXN];
int st[MAXN];

int main() {
//	freopen("E.in", "r", stdin);
//	freopen("E.out", "w", stdout);
	
	int n; scanf("%d", &n);
	assert((1 <= n) && (n <= 100000));
	a[0] = 1000000000;
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &a[i]);
		assert((0 <= a[i]) && (a[i] <= 100000));
	}
	
	int h = 0;
	st[h++] = 0;
	for (int i = 1; i <= n; ++i) {
		while (a[st[h - 1]] < a[i]) {
			--h;
		}
		if (st[h - 1] == 0) printf("OOPS\n");
		else printf("%d\n", st[h - 1]);
		st[h++] = i;
	}
	
	return 0;
}
