#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> v(n);
  for (auto &it : v) cin >> it;
  int min = *min_element(v.begin(), v.end());
  int max = *max_element(v.begin(), v.end());
  cout << max - min << '\n';
  return 0;
}
