/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;
/* Name of the class has to be "Main" only if the class is public. */
class Main
{
{
new Main().run();
}
class Item implements Comparable<Item> {
int x;
int ind;
Item(int x, int ind) {
this.x = x;
this.ind = ind;
}
public int compareTo(Item o) {
if (x < o.x)
return -1;
if (x > o.x)
return 1;
return ind - o.ind;
}
}
void run() {
try {
int n = nextInt();
TreeSet<Item> tree = new TreeSet<Item>();
int[] a = new int[n];
for (int i = 0; i < n; i++) {
a[i] = nextInt();
tree.add(new Item(a[i], i));
}
int m = nextInt();
for (int i = 0; i < m; i++) {
int q = nextInt();
if (q == 1) {
int x = nextInt();
Item toSearch = new Item(x, -1);
Item ceil = tree.ceiling(toSearch);
if (ceil == null || ceil.x != x)
out.println("Error");
else {
out.printf("%d\n", ceil.ind + 1);
}
} else {
int pos = nextInt() - 1;
int x = nextInt();
Item toDel = new Item(a[pos], pos);
tree.remove(toDel);
a[pos] = x;
Item toAdd = new Item(a[pos], pos);
tree.add(toAdd);
}
}
out.close();
e.printStackTrace(out);
out.flush();
out.close();
//while (true);
}
}
st.nextToken();
return (int) st.nval;
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CmltcG9ydCBqYXZhLm1hdGguKjsKCi8qIE5hbWUgb2YgdGhlIGNsYXNzIGhhcyB0byBiZSAiTWFpbiIgb25seSBpZiB0aGUgY2xhc3MgaXMgcHVibGljLiAqLwpjbGFzcyBNYWluCnsKICAgcHVibGljIHN0YXRpYyB2b2lkIG1haW4gKFN0cmluZ1tdIGFyZ3MpIHRocm93cyBqYXZhLmxhbmcuRXhjZXB0aW9uCiAgIHsKICAgICAgIG5ldyBNYWluKCkucnVuKCk7CiAgIH0KICAgCiAgIFN0cmVhbVRva2VuaXplciBzdDsKICAgCiAgIGNsYXNzIEl0ZW0gaW1wbGVtZW50cyBDb21wYXJhYmxlPEl0ZW0+IHsKICAgICAgIGludCB4OwogICAgICAgaW50IGluZDsKICAgICAgIEl0ZW0oaW50IHgsIGludCBpbmQpIHsKICAgICAgICAgICB0aGlzLnggPSB4OwogICAgICAgICAgIHRoaXMuaW5kID0gaW5kOwogICAgICAgfQogICAgICAgCiAgICAgICBwdWJsaWMgaW50IGNvbXBhcmVUbyhJdGVtIG8pIHsKICAgICAgICAgICBpZiAoeCA8IG8ueCkKICAgICAgICAgICAgICAgcmV0dXJuIC0xOwogICAgICAgICAgIGlmICh4ID4gby54KQogICAgICAgICAgICAgICByZXR1cm4gMTsKICAgICAgICAgICByZXR1cm4gaW5kIC0gby5pbmQ7CiAgICAgICB9CiAgIH0KICAgCiAgIFByaW50V3JpdGVyIG91dDsKCiAgIHZvaWQgcnVuKCkgewogICAgICAgdHJ5IHsKICAgICAgICAgICBzdCA9IG5ldyBTdHJlYW1Ub2tlbml6ZXIobmV3IEJ1ZmZlcmVkUmVhZGVyKG5ldyBJbnB1dFN0cmVhbVJlYWRlcihTeXN0ZW0uaW4pKSk7CiAgICAgICAgICAgb3V0ID0gbmV3IFByaW50V3JpdGVyKG5ldyBCdWZmZXJlZFdyaXRlcihuZXcgT3V0cHV0U3RyZWFtV3JpdGVyKFN5c3RlbS5vdXQpKSk7CiAgICAgICAgICAgaW50IG4gPSBuZXh0SW50KCk7CiAgICAgICAgICAgVHJlZVNldDxJdGVtPiB0cmVlID0gbmV3IFRyZWVTZXQ8SXRlbT4oKTsKICAgICAgICAgICBpbnRbXSBhID0gbmV3IGludFtuXTsKICAgICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8IG47IGkrKykgewogICAgICAgICAgICAgICBhW2ldID0gbmV4dEludCgpOwogICAgICAgICAgICAgICB0cmVlLmFkZChuZXcgSXRlbShhW2ldLCBpKSk7CiAgICAgICAgICAgfQogICAgICAgICAgIGludCBtID0gbmV4dEludCgpOwogICAgICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbTsgaSsrKSB7CiAgICAgICAgICAgICAgIGludCBxID0gbmV4dEludCgpOwogICAgICAgICAgICAgICBpZiAocSA9PSAxKSB7CiAgICAgICAgICAgICAgICAgICBpbnQgeCA9IG5leHRJbnQoKTsKICAgICAgICAgICAgICAgICAgIEl0ZW0gdG9TZWFyY2ggPSBuZXcgSXRlbSh4LCAtMSk7CiAgICAgICAgICAgICAgICAgICBJdGVtIGNlaWwgPSB0cmVlLmNlaWxpbmcodG9TZWFyY2gpOwogICAgICAgICAgICAgICAgICAgaWYgKGNlaWwgPT0gbnVsbCB8fCBjZWlsLnggIT0geCkKICAgICAgICAgICAgICAgICAgICAgICBvdXQucHJpbnRsbigiRXJyb3IiKTsKICAgICAgICAgICAgICAgICAgIGVsc2UgewogICAgICAgICAgICAgICAgICAgICAgIG91dC5wcmludGYoIiVkXG4iLCBjZWlsLmluZCArIDEpOwogICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgICAgaW50IHBvcyA9IG5leHRJbnQoKSAtIDE7CiAgICAgICAgICAgICAgICAgICBpbnQgeCA9IG5leHRJbnQoKTsKICAgICAgICAgICAgICAgICAgIEl0ZW0gdG9EZWwgPSBuZXcgSXRlbShhW3Bvc10sIHBvcyk7CiAgICAgICAgICAgICAgICAgICB0cmVlLnJlbW92ZSh0b0RlbCk7CiAgICAgICAgICAgICAgICAgICBhW3Bvc10gPSB4OwogICAgICAgICAgICAgICAgICAgSXRlbSB0b0FkZCA9IG5ldyBJdGVtKGFbcG9zXSwgcG9zKTsKICAgICAgICAgICAgICAgICAgIHRyZWUuYWRkKHRvQWRkKTsKICAgICAgICAgICAgICAgfQogICAgICAgICAgIH0KICAgICAgICAgICBvdXQuY2xvc2UoKTsKICAgICAgIH0gY2F0Y2ggKEV4Y2VwdGlvbiBlKSB7CiAgICAgICAgICAgZS5wcmludFN0YWNrVHJhY2Uob3V0KTsKICAgICAgICAgICBvdXQuZmx1c2goKTsKICAgICAgICAgICBvdXQuY2xvc2UoKTsKICAgICAgICAgICAvL3doaWxlICh0cnVlKTsKICAgICAgIH0KICAgfQogICAKICAgaW50IG5leHRJbnQoKSB0aHJvd3MgRXhjZXB0aW9uIHsKICAgICAgIHN0Lm5leHRUb2tlbigpOwogICAgICAgcmV0dXJuIChpbnQpIHN0Lm52YWw7CiAgIH0KCn0=