#include<iostream>
#include<stack>
using namespace std;
int main()
{
long int n;
int mount[10000], f[10000] = {0};
cin >> n;
stack<int>s;
for (int i = 0; i < n; i++)
cin >> mount[i];
for (int i = 0; i < n; i++)
{
if (s.size())
{
int si;
si = s.size();
for (int j = 0; j < si; j++)
{
if (mount[i] <= mount[s.top()])break;
if (mount[i] > mount[s.top()])
{
f[s.top()] = i + 1;
s.pop();
}
}
s.push(i);
}
else s.push(i);
}
for (int i = 0; i < n; i++)
cout << f[i];
return 0;
}