#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5;
const int INF = 1e9 + 7;
int main() {
  int n;
  scanf("%d", &n);
  vector<int> v;
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    v.push_back(x);
  }
  sort(v.begin(), v.end());
  long long ans = 0;
  for (int i = 1; i < v.size(); i++) {
    ans += 1ll * (v[i] - v[i - 1]);
  }
  cout << ans;
  return 0;
}
