#include <iostream>
#include <vector>
#include <cstdint>
#include <algorithm>
typedef std::vector<std::int64_t> DType;
DType::value_type MakeHoge(DType D) {
std::sort(D.begin(), D.end());
std::size_t i = 0;
for (i = 1; i < D.size() - 1; i++) {
if (D[i - 1] != D[i]) {
if (D[i] == D[i + 1])continue;
return D[i];
}
}
if (D[i] != D[i - 1])return D[i];
return -1;
}
int main() {
DType D = { 1,1,1,1,2,2,2,3,3,4 };
std::cout << MakeHoge(D) << std::endl;
D = DType{ 1,2,3,4,5,5,4,3,2,1 };
std::cout << MakeHoge(D) << std::endl;
D = DType{ 3,1,4,1,5,9,2,6,5,3,5 };
std::cout << MakeHoge(D) << std::endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8Y3N0ZGludD4KI2luY2x1ZGUgPGFsZ29yaXRobT4KCnR5cGVkZWYgc3RkOjp2ZWN0b3I8c3RkOjppbnQ2NF90PiBEVHlwZTsKCkRUeXBlOjp2YWx1ZV90eXBlIE1ha2VIb2dlKERUeXBlIEQpIHsKCglzdGQ6OnNvcnQoRC5iZWdpbigpLCBELmVuZCgpKTsKCXN0ZDo6c2l6ZV90IGkgPSAwOwoJCWZvciAoaSA9IDE7IGkgPCBELnNpemUoKSAtIDE7IGkrKykgewoJCWlmIChEW2kgLSAxXSAhPSBEW2ldKSB7CgkJCWlmIChEW2ldID09IERbaSArIDFdKWNvbnRpbnVlOwoKCQkJcmV0dXJuIERbaV07CgkJfQoJfQoJaWYgKERbaV0gIT0gRFtpIC0gMV0pcmV0dXJuIERbaV07CglyZXR1cm4gLTE7Cn0KCmludCBtYWluKCkgewoJRFR5cGUgRCA9IHsgMSwxLDEsMSwyLDIsMiwzLDMsNCB9OwoJc3RkOjpjb3V0IDw8IE1ha2VIb2dlKEQpIDw8IHN0ZDo6ZW5kbDsKCUQgPSBEVHlwZXsgMSwyLDMsNCw1LDUsNCwzLDIsMSB9OwoJc3RkOjpjb3V0IDw8IE1ha2VIb2dlKEQpIDw8IHN0ZDo6ZW5kbDsKCUQgPSBEVHlwZXsgMywxLDQsMSw1LDksMiw2LDUsMyw1IH07CglzdGQ6OmNvdXQgPDwgTWFrZUhvZ2UoRCkgPDwgc3RkOjplbmRsOwoJcmV0dXJuIDA7Cn0=