#!/bin/python3 import sys n = int(input().strip()) a = list(map(int, input().strip().split(' '))) # your code goes here a.sort() ma = max(a) mi = min(a) p = a.pop(a.index(mi)) print(ma-min(a))