#Include <iostream>
using namespace std;

const static int MAX = 10000;

int main() {
int R[MAX]={0};
int i;

for (int i=0; i < 10; i++ ) {
cin >> i;
R[i]=i;
}

for (int j=MAX - 1; j>0 ; j--){
int cnt = 0;

if  (cnt <= 3) break;

if (R[j] != 0){
cout << R[i] << endl;
cnt++;
}
return 0;
}



}