#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int srs[n];
  for (int i = 0; i < n; i++) {
    cin >> srs[i];
  }
  sort(srs, srs + n);
  int count = 0;
  for (int i = 0; i < n; i++) {
    if (srs[i] == srs[i + 1]) {
      count++;
    }
  }
  if (count >= 1)
    cout << n << endl;
  else {
    for (int i = 0; i < n; i++) {
      if (min(srs[i], srs[i + 1])) {
        cout << srs[n - 1] - srs[i] << endl;
        exit(0);
      }
    }
  }
  return 0;
}
