#include <iostream>
#include <vector>
#include <algorithm>
int main(){
    auto cmp = [](const int a,const int b)->bool{return a > b;};
    int n=0;
    std::vector<int> nums;
    while(std::cin >> n){
        nums.clear();
        while(n--){
            int temp = 0;
            std::cin >> temp;
            nums.push_back(temp);
        }
        std::make_heap(nums.begin(),nums.end(),cmp);
        std::pop_heap(nums.begin(),nums.end(),cmp);
        int before = nums.back();
        std::cout << before << std::endl;
        nums.pop_back();
        while(!nums.empty()){
            std::pop_heap(nums.begin(),nums.end(),cmp);
            if(nums.back() != before){
                before = nums.back();
                std::cout << before << std::endl;
            }
            nums.pop_back();
        }
    }

}