### constant

INF = 1 << 30

### main

loop do
  w, n = gets.split.map(&:to_i)
  break if (w | n) == 0

  wls = gets.split.map(&:to_i)
  #p wls

  msps = Array.new(n + 1){INF}
  msps[n - 1] = msps[n] = 0

  i = n - 1
  wsum = wls[i]
  loop do
    i -= 1
    break if i < 0
    wsum += 1 + wls[i]
    #puts "i=#{i},wsum=#{wsum}"
    break if wsum > w
    msps[i] = 1
  end

  while i >= 0
    #puts "i=#{i}"
    spsum = w - wls[i]
    k = 1
    while i + k < n
      spsum -= wls[i + k]
      break if spsum < k
      csp = (spsum + k - 1) / k
      k += 1
      sp = (csp >= msps[i + k]) ? csp : msps[i + k]
      #puts "  k=#{k},spsum=#{spsum},csp=#{csp},sp=#{sp}"
      msps[i] = sp if msps[i] > sp
    end

    i -= 1
  end

  #p msps
  puts msps[0]
end