#include <bits/stdc++.h>
using namespace std;
bool compare_by_b(pair<string, int64_t> a, pair<string, int64_t> b) {
  if (a.second != b.second)
    return a.second < b.second;
  else
    return a.first < b.first;
}
bool compare_by_a(pair<int64_t, int64_t> a, pair<int64_t, int64_t> b) {
  if (a.first != b.first)
    return a.first < b.first;
  else
    return a.second < b.second;
}
bool my_compare(pair<string, int64_t> a, pair<string, int64_t> b) {
  if (a.first != b.first) return a.first < b.first;
  if (a.second != b.second)
    return a.second > b.second;
  else
    return true;
}
int main() {
  int64_t n;
  cin >> n;
  vector<int64_t> a(n);
  vector<int64_t> b(n);
  for (int64_t i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  for (int64_t i = 0; i < n; i++) {
    vector<int64_t> b(a);
    b.erase(b.begin() + i);
    sort((b).begin(), (b).end());
    cout << b[n - 2] << endl;
  }
  return 0;
}
