#include <bits/stdc++.h>
using namespace std;
int main() {
  long int n, a[200000], max = 0, i, j = 0;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (i = 0; i < n; i++) {
    if (max < a[i]) {
      max = a[i];
    }
    if (j == n - 1) {
      j = 0;
      cout << max << endl;
      max = 0;
    } else {
      j++;
    }
  }
  return 0;
}
