#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  multiset<int> s;
  vector<int> v(n);
  int m = n;
  for (auto &i : v) {
    cin >> i;
    s.insert(i);
  }
  for (auto i : v) {
    s.erase(i);
    cout << *s.rbegin() << "\n";
    s.insert(i);
  }
  return 0;
}
