use std::{io::{BufRead, BufReader}, process::exit, cmp::Reverse};
fn main() {
let mut input = BufReader::new(std::io::stdin());
let mut line = "".to_string();
input.read_line(&mut line).unwrap();
let mut split = line.split_whitespace();
let n: u32 = split.next().unwrap().parse().unwrap();
let m: u32 = split.next().unwrap().parse().unwrap();
input = BufReader::new(std::io::stdin());
line = "".to_string();
input.read_line(&mut line).unwrap();
if n + m == 0{print!("0"); exit(0)}
split = line.split_whitespace();
let mut t: Vec<u32> = split.map(|x| x.parse::<u32>().unwrap()).collect();
t.sort_by_key(|w| Reverse(*w));
let mut s: Vec<u32> = vec![0; n.try_into().unwrap()];
let mut sa: Vec<u32> = vec![0; 5];
let mut pa: u32 =999999;
pa[0]+=1;
exit(0);
for _i in 0..m as usize{
for ii in 0..n as usize{
if ii as u32 == n - 1 {s[ii] += 1; pa = if pa > lyhyin(t[ii], s[ii]) {lyhyin(t[ii], s[ii])} else {pa}; break}
if pisin(t[ii], s[ii]) > pisin(t[ii+1], s[ii+1]){
s[ii] += 1;
pa = if pa > lyhyin(t[ii], s[ii]) {lyhyin(t[ii], s[ii])} else {pa};
break
}
}
print!("{} ",pisin(t[0], s[0]) - pa)
}
}
fn pisin(t: u32, s: u32) -> u32{
return t/(s + 1) + t%(s+1)
}
fn lyhyin(t: u32, s: u32) -> u32{
return t/(s + 1)
}