n, m = gets.split.map(&:to_i)
l = [[nil, 1]] + (1..n+1).map {|i| [i - 1, i + 1]}
m.times do |i|
    x = gets.to_i
    l[l[x][0]][1] = l[x][1]
    l[l[x][1]][0] = l[x][0]
    l[x][0] = 0
    l[x][1] = l[0][1]
    l[l[0][1]][0] = x
    l[0][1] = x
end
a = []
i = l[0][1]
until i > n
    a << i
    i = l[i][1]
end
puts a
