#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, temp;
  cin >> n;
  vector<int> nums(n);
  for (int i = 0; i < n; i++) cin >> nums[i];
  for (int i = 0; i < n; i++) {
    temp = nums[i];
    nums[i] = 0;
    cout << *max_element(nums.begin(), nums.end()) << endl;
    nums[i] = temp;
  }
  return 0;
}
