def solve():
    n = int(input())
    e = {}
    r = {}
    for i in range(n):
        x = int(input())
        if x in e:
            e[x] += 1
        else:
            e[x] = 1
    for key, value in e.items():
        if value >= 3:
            if 3 in r:
                r[3].append(key)
            else:
                r[3] = [key]
            continue
        if value in r:
            r[value].append(key)
        else:
            r[value] = [key]
    r[1].sort()
    r[2].sort()
    r[3].sort()
    answer = [None] * ((n + 1) // 2)
    for i in range(0, len(answer), 2):
        answer[i] = r[1].pop()
    x = 2
    for i in range(1, len(answer), 2):
        if x == 2:
            answer[i] = r[2].pop()
            x = 3
        else:
            answer[i] = r[3].pop()
            x = 2
    for i in range(len(answer)):
        print(answer[i], end=" ")

t = 1
while t > 0:
    solve()
    t -= 1


