import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    const N = readln.chomp.to!long;
    const as = readln.split.to!(long[]);
    writeln(as.reduce!max - as.reduce!min);
}

