#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, house[1005], i, ans;
  ans = 0;
  cin >> N;
  for (i = 0; i < N; i++) {
    cin >> house[i];
  }
  sort(house, house + N, greater<int>());
  cout << house[0] - house[N] << endl;
}
