#include <bits/stdc++.h>
using namespace std;
bool compare_by_b(pair<long long, long long> a, pair<long long, long long> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}
signed main() {
  long long x = 0, y = 0, z = 0, w = 0, n = 0, m = 0;
  std::cin >> x;
  std::vector<long long> v(x);
  std::vector<long long> vv(x);
  for (long long i = 0; i < (long long)(x); ++i) {
    std::cin >> v[i];
  }
  vv = v;
  for (long long i = 0; i < (long long)(x); ++i) {
    v = vv;
    (v).erase(v.begin() + (i));
    sort((v).rbegin(), (v).rend());
    std::cout << v[0] << '\n';
  }
}
