#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int ans = 0;
  vector<int> v;
  for (int x = 0; x < n; x++) {
    int a;
    cin >> a;
    v.push_back(a);
  }
  sort(v.begin(), v.end());
  ans = v[n - 1] - v[0];
  cout << ans << endl;
}
