#include <bits/stdc++.h>
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int ny, nx;
using namespace std;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long m, long long n) {
  if ((0 == m) || (0 == n)) return 0;
  return ((m / gcd(m, n)) * n);
}
long long llpow(long long x, long long y) {
  long long ans = 1;
  for (int i = 0, i_len = (y); i < i_len; ++i) ans *= x;
  return ans;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
class UnionFind {
 public:
  vector<long long> par;
  vector<long long> siz;
  UnionFind(long long sz_) : par(sz_), siz(sz_, 1LL) {
    for (long long i = 0; i < sz_; ++i) par[i] = i;
  }
  void init(long long sz_) {
    siz.assign(sz_, 1LL);
    par.resize(sz_);
    for (long long i = 0; i < sz_; ++i) par[i] = i;
  }
  long long root(long long x) {
    while (par[x] != x) {
      x = par[x] = par[par[x]];
    }
    return x;
  }
  bool merge(long long x, long long y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (siz[x] < siz[y]) swap(x, y);
    siz[x] += siz[y];
    par[y] = x;
    return true;
  }
  bool issame(long long x, long long y) { return root(x) == root(y); }
  long long size(long long x) { return siz[root(x)]; }
};
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v) {
  return (c.end() != std::find(c.begin(), c.end(), v));
}
vector<long long> decom;
void decompositPrime(long long n) {
  long long a = 2;
  while (n >= a * a) {
    if (n % a == 0) {
      decom.push_back(a);
      n /= a;
    } else {
      a++;
    }
  }
  decom.push_back(n);
}
int ctoi_alpha(char c) {
  if (c >= 'a' && c <= 'z') {
    return c - 'a';
  }
  return 0;
}
const int MOD = 1000000007;
vector<vector<int>> calcNext(const string &S) {
  int n = (int)S.size();
  vector<vector<int>> res(n + 1, vector<int>(26, n));
  for (int i = n - 1; i >= 0; --i) {
    for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
    res[i][S[i] - 'a'] = i;
  }
  return res;
}
void add(long long &a, long long b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0, i_len = (N); i < i_len; ++i) cin >> A[i];
  for (int i = 0, i_len = (N); i < i_len; ++i) {
    vector<int> res;
    for (int j = 0, j_len = (N); j < j_len; ++j) {
      if (j != i) res.push_back(A[j]);
    }
    cout << *max_element(res.begin(), res.end()) << endl;
  }
  return 0;
}
