var
  n,max,min,x:longint;
begin
  readln(n);
  max:=-maxlongint;min:=maxlongint;
  for i:=1 to n do
    begin
      read(x);
      if x>max then max:=x;
      if x<min then min:=x;
    end;
  writeln(max-min);
end.