C++ 代码
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 100010;
int a[N];
int l = N;
int r;
int main(){
// freopen ("a.in","r",stdin);
// freopen ("a.out","w",stdout);
int n;
cin >> n;
int id;
while(cin >> id){
a[id]++;
l = min(l, id);
r = max(r, id);
}
int a1,a2;
for(int i = l; i <= r; i++){
if (a[i] == 0) a1 = i;
if (a[i] == 2) a2 = i;
}
cout << a1 << " " << a2;
return 0;
}