#include <bits/stdc++.h>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
using namespace std;
using Graph = vector<vector<int>>;
using Graph_weighted = vector<vector<pair<int, int>>>;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
long long ceil(const long long a, const long long b) { return (a + b - 1) / b; }
class segment_tree_Sum {
 private:
  vector<long long> seg;
  int seg_size = (1 << 18) * 2;

 public:
  segment_tree_Sum() { seg.resize(seg_size); }
  void update(int ind, int n) {
    ind += (1 << 18);
    seg[ind] = n;
    while (true) {
      ind /= 2;
      if (ind == 0) break;
      seg[ind] = seg[ind * 2] + seg[ind * 2 + 1];
    }
  }
  long long Sum(int l, int r) {
    l += (1 << 18);
    r += (1 << 18) + 1;
    long long ans = 0;
    while (l < r) {
      if (l % 2 == 1) {
        ans += seg[l];
        l++;
      }
      if (l >= r) break;
      l /= 2;
      if (r % 2 == 1) {
        ans += seg[r - 1];
        r--;
      }
      r /= 2;
    }
    return ans;
  }
};
class segment_tree_Min {
 private:
  vector<long long> seg;
  int seg_size = (1 << 18) * 2;

 public:
  segment_tree_Min() {
    seg.resize(seg_size);
    for (int i = 0; i < seg_size; i++) seg[i] = -INF;
  }
  void update(int ind, int n) {
    ind += (1 << 18);
    seg[ind] = n;
    while (true) {
      ind /= 2;
      if (ind == 0) break;
      seg[ind] = min(seg[ind * 2], seg[ind * 2 + 1]);
    }
  }
  long long Min(int l, int r) {
    l += (1 << 18);
    r += (1 << 18) + 1;
    long long ans = -INF;
    while (l < r) {
      if (l % 2 == 1) {
        ans = min(seg[l], ans);
        l++;
      }
      if (l >= r) break;
      l /= 2;
      if (r % 2 == 1) {
        ans = min(seg[r - 1], ans);
        r--;
      }
      r /= 2;
    }
    return ans;
  }
};
int main() {
  int n;
  cin >> n;
  segment_tree_Min seg;
  for (int i = 0; i < (n); ++i) {
    int tmp;
    cin >> tmp;
    seg.update(i, tmp);
  }
  for (int i = 0; i < (n); ++i) {
    if (i == 0) {
      cout << seg.Min(1, n - 1) << endl;
    }
    if (i == n - 1) {
      cout << seg.Min(0, n - 2) << endl;
    }
    cout << min(seg.Min(0, i - 1), seg.Min(i + 1, n - 1)) << endl;
  }
  return 0;
}
