#include <iostream>
#include <algorithm>
using namespace std;
pair<int, int> t[1001];
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
int a;
cin>>a;
t[i] = make_pair(a, i);
}
// use block-sort if needed
int len = 0;
for (int i = n; i >= 1; i--) {
if (t[i].first != t[i - 1].first) {
len++;
} else {
swap(t[i], t[i + len]);
}
}
sort(t + 1, t + 1 + len);
for (int i = 1; i <= n; i++) {
cout<<"("<<t[i].first<<", "<<t[i].second<<") ";
}
cout<<endl;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8YWxnb3JpdGhtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwogCnBhaXI8aW50LCBpbnQ+IHRbMTAwMV07CiAKaW50IG1haW4oKSB7CglpbnQgbjsKCWNpbiA+PiBuOwoJZm9yIChpbnQgaSA9IDE7IGkgPD0gbjsgaSsrKSB7CgkJaW50IGE7CgkJY2luPj5hOwoJCXRbaV0gPSBtYWtlX3BhaXIoYSwgaSk7Cgl9CgkvLyB1c2UgYmxvY2stc29ydCBpZiBuZWVkZWQKCWludCBsZW4gPSAwOwoJZm9yIChpbnQgaSA9IG47IGkgPj0gMTsgaS0tKSB7CgkJaWYgKHRbaV0uZmlyc3QgIT0gdFtpIC0gMV0uZmlyc3QpIHsKCQkJbGVuKys7CgkJfSBlbHNlIHsKCQkJc3dhcCh0W2ldLCB0W2kgKyBsZW5dKTsKCQl9Cgl9Cglzb3J0KHQgKyAxLCB0ICsgMSArIGxlbik7Cglmb3IgKGludCBpID0gMTsgaSA8PSBuOyBpKyspIHsKCQljb3V0PDwiKCI8PHRbaV0uZmlyc3Q8PCIsICI8PHRbaV0uc2Vjb25kPDwiKSAiOwoJfQoJY291dDw8ZW5kbDsKfQ==
(1, 1) (2, 6) (3, 10) (4, 12) (1, 2) (1, 3) (1, 4) (1, 5) (2, 7) (2, 8) (2, 9) (3, 11) (4, 13) (4, 14) (4, 15) (4, 16)