#include <bits/stdc++.h>
using namespace std;

int main () {
  int n; cin >> n;
  queue<int> q;
  for (int i=0;i<n;i++) {
    int x; cin >> x;
    q.push(x);
  }
  for (int i=0;i<n;i++) {
    int a = q.front();
    q.pop();
    priority_queue<int> p;
    p = q;
    cout << p.top() << endl;
    q.push(a);
  }
}
