#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cmath>
#include <stack>
#include <cctype>
#include <stdio.h>

using namespace std;

int a[200010];

int main() {

  int n=0,k=0;
  cin>>n>>k;

  int max =0;
  int min =1001;
  int tmp;
  for(int i=0; i<n;i++){
	  cin>>tmp;
	  if(max<tmp){
		  max =tmp;
	  }
	  if(min>tmp){
		  min =tmp;
	  }
  }
  stringstream ss;
  ss<<max-min;

  cout<<ss.str()<<endl;

	return 0;
}