#include <iostream>
#include <vector>
#include <cmath>

int main(int argc, char *argv[]){
  unsigned int N;
  std::cin >> N;
  std::vector<unsigned int>A(N);
  for(auto &a : A){
    std::cin >> a;
  }
  unsigned int a;
  for(int i=0; i<N; ++i){
    a = A[i]
    A.erase(A.begin()+i);
    std::cout << *std::max_element(A.begin(),A.end());
    A.insert(A.begin()+i,a)
  }
  return 0;
}