#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const int MINF = -1e9;
;
int main() {
  int n;
  vector<int> a;
  cin >> n;
  a.resize(n);
  for (int i = (int)0; i < (int)n; ++i) {
    cin >> a[i];
  }
  for (int i = (int)0; i < (int)n; ++i) {
    vector<int> x(a.size());
    copy(a.begin(), a.end(), x.begin());
    x.erase(x.begin() + i);
    sort(x.begin(), x.end());
    cout << x.at(n - 2) << endl;
  }
  return 0;
}
