#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, d, ans;
  int fd0, i;
  fd0 = 0;
  i = 0;
  cin >> a;
  while (fd0 == 0) {
    i = i + 1;
    cin >> b;
    if (b == -100) {
      fd0 = -1;
    } else if (a != i) {
      ans = max(ans, b);
    }
    b = -100;
  }
  cout << ans;
  return 0;
}
