#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  vector<int> a;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
  vector<int> tmpa(a.size());
  copy(a.begin(), a.end(), tmpa.begin());
  sort(tmpa.begin(), tmpa.end());
  int max = tmpa.back();
  for (int i = 0; i < n; i++) {
    vector<int> tmptmpa(a.size());
    copy(a.begin(), a.end(), tmptmpa.begin());
    if (tmptmpa[i] == max) {
      tmptmpa.erase(tmptmpa.begin() + i);
      sort(tmptmpa.begin(), tmptmpa.end());
      cout << tmptmpa.back() << endl;
    } else {
      cout << max << endl;
    }
  }
}
