const
	MAXN = 200000;

var
	a, st: array [0..MAXN] of longint;
	n, h, i: longint;

begin
//	assign(input, 'E.in'); reset(input);
//	assign(output, 'E.out'); rewrite(output);
	
	readln(n);
	a[0] := 1000000000;
	for i := 1 to n do
	begin
		read(a[i]);
	end;
	
	h := 0;
	st[h] := 0;
	inc(h);
	for i := 1 to n do
	begin
		while (a[st[h - 1]] < a[i]) do
		begin
			dec(h);
		end;
		if st[h - 1] = 0 then writeln('OOPS')
		else writeln(st[h - 1]);
		st[h] := i;
		inc(h);
	end;
	
	close(output);
end.
