#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
inline void Main() {
  int n, a[200000], b[200000];
  cin >> n;
  for (int i = (int)(0); i < (int)(n); ++i) cin >> a[i];
  for (int i = (int)(0); i < (int)(n); ++i) {
    memcpy(b, a, sizeof(a));
    b[i] = 0;
    sort(b, b + n);
    cout << b[n - 1] << endl;
  }
}
int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  Main();
  return 0;
}
