#include <iostream>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, i=0;
  cin >> N;
  vector<int> vec(N);
  vector<int> copy;
  while(cin >> l){
    vec[i] = l;
    i++;
  }
  int max;
  size_t maxIndex;
  
  for(i = 0; i < N; i++){
    memcpy(copy, vec, sizeof(int) * N);
    copy.erase(copy.begin() + i);
  	cout >> *std::max_element(copy.begin(), copy.end()) >> "\n";
  }
  
}