#![allow(dead_code)] #![allow(non_snake_case)] macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); input_inner!{iter, $($r)*} }; ($($r:tt)*) => { let mut s = { use std::io::Read; let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); s }; let mut iter = s.split_whitespace(); input_inner!{iter, $($r)*} }; } macro_rules! input_inner { ($iter:expr) => {}; ($iter:expr, ) => {}; ($iter:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($iter, $t); input_inner!{$iter $($r)*} }; } macro_rules! read_value { ($iter:expr, ( $($t:tt),* )) => { ( $(read_value!($iter, $t)),* ) }; ($iter:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($iter, $t)).collect::>() }; ($iter:expr, chars) => { read_value!($iter, String).chars().collect::>() }; ($iter:expr, usize1) => { read_value!($iter, usize) - 1 }; ($iter:expr, $t:ty) => { $iter.next().unwrap().parse::<$t>().expect("Parse error") }; } struct Combination { MOD: u64, size: usize, fact: Vec, inv_fact: Vec } impl Combination { fn new(size: usize, MOD: u64) -> Self { let mut fact = vec![1; size + 1]; let mut inv_fact = vec![1; size + 1]; for i in 1..size+1 { fact[i] = fact[i-1] * i as u64 % MOD; } inv_fact[size] = Self::modpow(fact[size], MOD-2, MOD); for i in (1..size+1).rev() { inv_fact[i-1] = inv_fact[i] * i as u64 % MOD; } Combination { MOD, size, fact, inv_fact } } fn modpow(mut x:u64, mut y:u64, m:u64) -> u64 { let mut res: u64 = 1; while y > 0 { if y & 1 > 0 { res = res * x % m; } x = x * x % m; y >>= 1; } res } fn modinv(x: u64, m:u64) -> u64 { Self::modpow(x, m-2, m) } fn nPr (&self, n:usize, r:usize) -> u64 { if n < r { return 0 }; self.fact[n] * self.inv_fact[n-r] % self.MOD } fn nCr (&self, n:usize, r:usize) -> u64 { if n < r { return 0 }; self.fact[n] * self.inv_fact[r] % self.MOD * self.inv_fact[n-r] % self.MOD } } fn main() { input!{ n:usize, s:[i32; n] } let mut v = s[n-1] - s[0]; for i in 0..n-1 { v = std::cmp::min(v, s[i+1]-s[i]); } println!("{}", v); println!("{}", s[n-1] - s[0]); }