#include
#include
int compare(void *a, void *b) {
int va = *(int*)a;
int vb = *(int*)b;
if(va == vb) return 0;
return va < vb ? -1 : 1;
}
int max_index(void *base, int n, int width, int (*compare)(void *a, void *b)) {
int i, j = 0;
char max[width];
memcpy(max, base, width);
for(i = 1; i < n; i++) {
if( compare(base+i*width, max) > 0)
{
memcpy(max, base+i*width, width);
j = i;
}
}
return j;
}
int main() {
int n;
scanf("%d", &n);
int a[n];
for(int i = 0; i < n; i++)
scanf("%d", &a[i]);
printf("%d\n", a[max_index(a, n, sizeof(int), compare)]);
}