#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  vector<long long> a;
  for (long long i = 0; i < n; i++) {
    long long x;
    cin >> x;
    a.push_back(x);
  }
  long long m = a[n - 1];
  for (long long i = n - 1; i >= 0; i--) {
    m = max(a[i], m);
    a[i] = m;
  }
  vector<long long>::iterator i;
  for (i = a.begin(); i != a.end(); i++) cout << *i << " ";
  return 0;
}
