#include<bits/stdc++.h>
using namespace std;
int main()
{
  	int n;
  	cin >> n;
  	vector< int > a(n);
  	int b[n]
  	for(int i = 0 ; i < n ; i++){
      cin >> a[i];
      b[i] = a[i];
    }
  	sort(a.begin() , a.end() );
  	for(int i = 0 ; i < n ; i++){
      int pos = lower_bound(a.begin() , a.end() , b[i]) - a.begin();
      if(pos == (n - 1))	cout << a[pos - 1] << endl;
      else cout << a[n - 1 ] << endl;
    }
 	return 0; 
}