#include <iostream>
#include <vector>
using namespace std;
#define saleh \
ios_base::sync_with_stdio(false); \
cin.tie(nullptr);
#define ll long long
int n;
struct node
{
int l = -1, r = -1;
};
struct segTree
{
int size;
vector<int> segData;
void build(int n)
{
size = 1;
while (size < n)
size *= 2;
segData.assign(2 * size, 0);
}
void update(int ind, int x, int lx, int rx)
{
if (rx - lx == 1)
{
segData[x] = 0;
return;
}
int mid = (lx + rx) / 2;
if (ind < mid)
{
update(ind, 2 * x + 1, lx, mid);
}
else
{
update(ind, 2 * x + 2, mid, rx);
}
segData[x] = segData[2 * x + 1] + segData[2 * x + 2];
}
void update(int ind)
{
update(ind, 0, 0, size);
}
int queury(int l, int r, int x, int lx, int rx)
{
if (lx >= r || l >= rx)
return 0;
if (lx >= l && rx <= r)
return segData[x];
int mid = (lx + rx) / 2;
int leftpart = queury(l, r, 2 * x + 1, lx, mid);
int rightpart = queury(l, r, 2 * x + 2, mid, rx);
return leftpart + rightpart;
}
int queury(int l, int r)
{
return queury(l, r, 0, 0, size);
}
void build(int x, int lx, int rx)
{
if (rx - lx == 1)
{
if (lx < 2 * n)
{
segData[x] = 1;
}
return;
}
int mid = (lx + rx) / 2;
build(2 * x + 1, lx, mid);
build(2 * x + 2, mid, rx);
segData[x] = segData[2 * x + 1] + segData[2 * x + 2];
}
void buildons()
{
build(0, 0, size);
}
};
void solve()
{
cin >> n;
vector<node> p(n);
vector<int> v(n * 2);
for (int i = 0; i < n * 2; i++)
{
cin >> v[i];
v[i]--;
}
for (int i = 0; i < n * 2; i++)
{
int x = v[i];
if (p[x].l == -1)
p[x].l = i;
else
p[x].r = i;
}
segTree segment;
segment.build(n * 2);
segment.buildons();
vector<int> result(n);
for (int i = 0; i < n * 2; i++)
{
if (p[v[i]].l != -1)
{
result[v[i]] = ((segment.queury(p[v[i]].l + 1, p[v[i]].r)) / 2);
segment.update(p[v[i]].l);
segment.update(p[v[i]].r);
p[v[i]].l = -1;
}
}
for (auto a : result)
cout << a << " ";
}
int main()
{
saleh;
solve();
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCiNkZWZpbmUgc2FsZWggICAgICAgICAgICAgICAgICAgICAgICAgXAogICAgaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbyhmYWxzZSk7IFwKICAgIGNpbi50aWUobnVsbHB0cik7CiNkZWZpbmUgbGwgbG9uZyBsb25nCgppbnQgbjsKCnN0cnVjdCBub2RlCnsKICAgIGludCBsID0gLTEsIHIgPSAtMTsKfTsKCnN0cnVjdCBzZWdUcmVlCnsKICAgIGludCBzaXplOwogICAgdmVjdG9yPGludD4gc2VnRGF0YTsKCiAgICB2b2lkIGJ1aWxkKGludCBuKQogICAgewogICAgICAgIHNpemUgPSAxOwogICAgICAgIHdoaWxlIChzaXplIDwgbikKICAgICAgICAgICAgc2l6ZSAqPSAyOwogICAgICAgIHNlZ0RhdGEuYXNzaWduKDIgKiBzaXplLCAwKTsKICAgIH0KCiAgICB2b2lkIHVwZGF0ZShpbnQgaW5kLCBpbnQgeCwgaW50IGx4LCBpbnQgcngpCiAgICB7CiAgICAgICAgaWYgKHJ4IC0gbHggPT0gMSkKICAgICAgICB7CiAgICAgICAgICAgIHNlZ0RhdGFbeF0gPSAwOwogICAgICAgICAgICByZXR1cm47CiAgICAgICAgfQogICAgICAgIGludCBtaWQgPSAobHggKyByeCkgLyAyOwogICAgICAgIGlmIChpbmQgPCBtaWQpCiAgICAgICAgewogICAgICAgICAgICB1cGRhdGUoaW5kLCAyICogeCArIDEsIGx4LCBtaWQpOwogICAgICAgIH0KICAgICAgICBlbHNlCiAgICAgICAgewogICAgICAgICAgICB1cGRhdGUoaW5kLCAyICogeCArIDIsIG1pZCwgcngpOwogICAgICAgIH0KICAgICAgICBzZWdEYXRhW3hdID0gc2VnRGF0YVsyICogeCArIDFdICsgc2VnRGF0YVsyICogeCArIDJdOwogICAgfQogICAgdm9pZCB1cGRhdGUoaW50IGluZCkKICAgIHsKICAgICAgICB1cGRhdGUoaW5kLCAwLCAwLCBzaXplKTsKICAgIH0KCiAgICBpbnQgcXVldXJ5KGludCBsLCBpbnQgciwgaW50IHgsIGludCBseCwgaW50IHJ4KQogICAgewogICAgICAgIGlmIChseCA+PSByIHx8IGwgPj0gcngpCiAgICAgICAgICAgIHJldHVybiAwOwogICAgICAgIGlmIChseCA+PSBsICYmIHJ4IDw9IHIpCiAgICAgICAgICAgIHJldHVybiBzZWdEYXRhW3hdOwoKICAgICAgICBpbnQgbWlkID0gKGx4ICsgcngpIC8gMjsKICAgICAgICBpbnQgbGVmdHBhcnQgPSBxdWV1cnkobCwgciwgMiAqIHggKyAxLCBseCwgbWlkKTsKICAgICAgICBpbnQgcmlnaHRwYXJ0ID0gcXVldXJ5KGwsIHIsIDIgKiB4ICsgMiwgbWlkLCByeCk7CiAgICAgICAgcmV0dXJuIGxlZnRwYXJ0ICsgcmlnaHRwYXJ0OwogICAgfQoKICAgIGludCBxdWV1cnkoaW50IGwsIGludCByKQogICAgewogICAgICAgIHJldHVybiBxdWV1cnkobCwgciwgMCwgMCwgc2l6ZSk7CiAgICB9CgogICAgdm9pZCBidWlsZChpbnQgeCwgaW50IGx4LCBpbnQgcngpCiAgICB7CiAgICAgICAgaWYgKHJ4IC0gbHggPT0gMSkKICAgICAgICB7CiAgICAgICAgICAgIGlmIChseCA8IDIgKiBuKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBzZWdEYXRhW3hdID0gMTsKICAgICAgICAgICAgfQoKICAgICAgICAgICAgcmV0dXJuOwogICAgICAgIH0KICAgICAgICBpbnQgbWlkID0gKGx4ICsgcngpIC8gMjsKICAgICAgICBidWlsZCgyICogeCArIDEsIGx4LCBtaWQpOwogICAgICAgIGJ1aWxkKDIgKiB4ICsgMiwgbWlkLCByeCk7CiAgICAgICAgc2VnRGF0YVt4XSA9IHNlZ0RhdGFbMiAqIHggKyAxXSArIHNlZ0RhdGFbMiAqIHggKyAyXTsKICAgIH0KICAgIHZvaWQgYnVpbGRvbnMoKQogICAgewogICAgICAgIGJ1aWxkKDAsIDAsIHNpemUpOwogICAgfQp9OwoKdm9pZCBzb2x2ZSgpCnsKICAgIGNpbiA+PiBuOwoKICAgIHZlY3Rvcjxub2RlPiBwKG4pOwogICAgdmVjdG9yPGludD4gdihuICogMik7CiAgICBmb3IgKGludCBpID0gMDsgaSA8IG4gKiAyOyBpKyspCiAgICB7CiAgICAgICAgY2luID4+IHZbaV07CiAgICAgICAgdltpXS0tOwogICAgfQoKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbiAqIDI7IGkrKykKICAgIHsKICAgICAgICBpbnQgeCA9IHZbaV07CiAgICAgICAgaWYgKHBbeF0ubCA9PSAtMSkKICAgICAgICAgICAgcFt4XS5sID0gaTsKICAgICAgICBlbHNlCiAgICAgICAgICAgIHBbeF0uciA9IGk7CiAgICB9CgogICAgc2VnVHJlZSBzZWdtZW50OwogICAgc2VnbWVudC5idWlsZChuICogMik7CiAgICBzZWdtZW50LmJ1aWxkb25zKCk7CgogICAgdmVjdG9yPGludD4gcmVzdWx0KG4pOwoKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbiAqIDI7IGkrKykKICAgIHsKICAgICAgICBpZiAocFt2W2ldXS5sICE9IC0xKQogICAgICAgIHsKICAgICAgICAgICAgcmVzdWx0W3ZbaV1dID0gKChzZWdtZW50LnF1ZXVyeShwW3ZbaV1dLmwgKyAxLCBwW3ZbaV1dLnIpKSAvIDIpOwogICAgICAgICAgICBzZWdtZW50LnVwZGF0ZShwW3ZbaV1dLmwpOwogICAgICAgICAgICBzZWdtZW50LnVwZGF0ZShwW3ZbaV1dLnIpOwogICAgICAgICAgICBwW3ZbaV1dLmwgPSAtMTsKICAgICAgICB9CiAgICB9CiAgICBmb3IgKGF1dG8gYSA6IHJlc3VsdCkKICAgICAgICBjb3V0IDw8IGEgPDwgIiAiOwp9CgppbnQgbWFpbigpCnsKICAgIHNhbGVoOwogICAgc29sdmUoKTsKICAgIHJldHVybiAwOwp9Cg==