1 #include<iostream>
2 #include<cstdio>
3 using namespace std;
4 int a[100001];
5 int b[100001];
6 int c[100001];
7 int main()
8 {
9 int n;
10 cin>>n;
11 for(int i=1;i<=n;i++)
12 {
13 cin>>a[i];
14 if(a[i]==1)
15 {
16 cin>>b[i];
17 }
18 }
19 int heap=0,tail=0;
20 for(int i=1;i<=n;i++)
21 {
22 if(a[i]==1)
23 {
24 tail++;
25 a[tail]=b[i];
26 }
27 if(a[i]==2)
28 {
29 heap++;
30 }
31 if(heap>tail)
32 {
33 cout<<"impossible!";
34 return 0;
35 }
36 }
37 if(heap==tail)
38 {
39 cout<<"impossible!";
40 return 0;
41 }
42 cout<<a[heap+1];
43 return 0;
44 }