use std::cmp::*; use std::io::*; use std::str::FromStr; use utils::*; pub fn main() { let i = stdin(); let mut o = Vec::new(); run(i.lock(), &mut o); stdout().write_all(&o).unwrap(); } fn run(i: R, o: &mut W) { let mut i = ReadEx::from(i); let n = i.read::(); let _ = i.read::(); let mut max_value = usize::min_value(); let mut min_value = usize::max_value(); for _ in 0..n { let value = i.read::(); max_value = max(max_value, value); min_value = min(min_value, value); } writeln!(o, "{}", max_value - min_value).unwrap(); } mod utils { use super::*; pub struct ReadEx { r: R, s: String, } impl ReadEx { pub fn from(r: R) -> Self { ReadEx { r: r, s: String::new(), } } pub fn read_line(&mut self) -> &str { self.s.clear(); self.r.read_line(&mut self.s).unwrap(); self.s.trim() } pub fn read(&mut self) -> T { self.read_line().parse().ok().unwrap() } } }