loop do
  n, k = gets.split.map(&:to_i)
  break if n == 0
  c = []
  k.times { c << gets.to_i }
  c.sort!

  pos = 1
  pos = 2 if c[0] == 0
  r = [[c[pos - 1]]]
  pos.upto(k-1) do |i|
    if c[i] == c[i - 1] + 1
      r.last << c[i]
    else
      r << [c[i]]
    end
  end

  if c.include? 0
    max = 0
    r.each_cons(2) do |a, b|
      max = [max, a.size + b.size + 1].max
    end
    puts max
  else
    puts r.max_by { |e| e.size }.size
  end
end