#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
template <typename T>
struct Edge {
  int u, v;
  T cost;
  Edge(int u, int v, T c) : u(u), v(v), cost(c) {}
  bool operator<(const Edge &e) const { return cost < e.cost; }
};
static const long long MOD = 1000000007;
static const long long LINF = (long long)(1e18 + 99);
static const int INF = 1e9 + 99;
long long ans;
int main(void) {
  int N;
  cin >> N;
  vector<long long> A(N, 0);
  for (int i = (0); i < (N); i++) cin >> A[i];
  sort((A).begin(), (A).end());
  for (int i = (1); i < (N); i++) ans += A[i] - A[i - 1];
  cout << ans << endl;
  return 0;
}
