Mike is the president of country What-The-Fatherland. There are *n* bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to *n* from left to right. *i*-th bear is exactly *a*<sub class="lower-index">*i*</sub> feet high. 

A group of bears is a non-empty contiguous segment of the line. The size of a group is the number of bears in that group. The strength of a group is the minimum height of the bear in that group.

Mike is a curious to know for each *x* such that 1 ≤ *x* ≤ *n* the maximum strength among all groups of size *x*.
The first line of input contains integer *n* (1 ≤ *n* ≤ 2 × 10<sup class="upper-index">5</sup>), the number of bears.

The second line contains *n* integers separated by space, *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub> (1 ≤ *a*<sub class="lower-index">*i*</sub> ≤ 10<sup class="upper-index">9</sup>), heights of bears.
class DisjointSet:

    """Class for data structure Disjoint Set Union"""

    def __init__(self, capacity: int):

        """
        Constructor for an object of a class of a system of disjoint sets

        Parameters:
        ----------
        capacity: int
            Number of elements that will be split into disjoint sets

        Returns:
        -------
            Object of DisjointSet-class
        """

        self.parent = [i for i in range(capacity)]
        self.rank = [0] * capacity

    def find_root(self, a):
        if self.parent[a] == a:
            return a
        return self.find_root(self.parent[a])

    def merge_sets(self, a, b):

        """
        Method of merging two sets in one in current dta structure

        Parameters:
        ----------
        a: int
            First set for merging
        b: int
            Second set for merging
        """

        a = self.find_root(a)
        b = self.find_root(b)
        if a != b:
            if self.rank[a] < self.rank[b]:
                c = a
                a = b
                b = c
            self.parent[b] = a
            if self.rank[a] == self.rank[b]:
                self.rank[a] += 1


def task2(childs: list) -> list:

    """
    Task to find the minimum strength of a subgroup

    Parameters:
    ----------
    pandas: list
        Panda heights list

    Returns:
    -------
        List of maximum group powers
    """

    strengths = [0] * len(childs)
    for i in range(len(childs)):
        total_set = DisjointSet(len(childs))
        for set_len in range(1, len(childs) + 1 - i):
            for j in range(i + 1, i + set_len):
                total_set.merge_sets(i, j)
            min_strength = float("inf")
            for ind, set_elem in enumerate(total_set.parent):
                if total_set.find_root(set_elem) == i:
                    min_strength = min(min_strength, childs[ind])
            strengths[set_len - 1] = max(strengths[set_len - 1], min_strength)

    return strengths

a = int(input())
arr = list(map(int, input().split()))
print(*task2(arr))
