#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int a[N + 1];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  int max = a[0];
  int min = a[0];
  for (int i = 0; i < N + 1; i++) {
    if (a[i] < a[i + 1]) max = a[i + 1];
    if (a[i] > a[i + 1]) min = a[i + 1];
  }
  cout << max - min << endl;
  return 0;
}
