use std::cmp;

fn main() {

    let scan = std::io::stdin();

    let mut line = String::new();

    scan.read_line(&mut line);
    let n = line.parse().unwrap_or(0);
    scan.read_line(&mut line);

    let vec: Vec<&str> = line.split_whitespace().collect();

    let mut min = i32::max_value();
    let mut max = i32::min_value();;
    for s in vec{
        let a = s.parse().unwrap_or(0);
        min = cmp::min(min, a);
        max = cmp::max(max, a);
    }
    println!("{}",max - min);
}