#include <bits/stdc++.h>
using namespace std;
long long getMax(long long num, vector<long long> sorted) {
  long long size = sorted.size();
  long long left = 0;
  long long right = size - 1;
  long long max = sorted.at(size - 1);
  long long mid, ans;
  while (right >= left) {
    mid = left + (right - left) / 2;
    if (sorted.at(mid) == num) {
      break;
    } else if (sorted.at(mid) > num) {
      right = mid - 1;
    } else if (sorted.at(mid) < num) {
      left = mid + 1;
    }
  }
  if (mid == size - 1) {
    ans = sorted.at(mid - 1);
  } else if (mid < size) {
    ans = max;
  }
  return ans;
}
int main() {
  long long n;
  cin >> n;
  vector<long long> a(n), ans(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (long long x = 0; x < n; x++) {
    vector<long long> b(n);
    copy(a.begin(), a.end(), b.begin());
    sort(b.begin(), b.end());
    ans[x] = getMax(a.at(x), b);
  }
  for (long long answer : ans) {
    cout << answer << endl;
  }
  return 0;
}
