#include #include #include #include #include #include #include #include using namespace std; int main(){ int N; cin >> N; int x = 0; vector v; for(int i = 0; i < N; i++){ cin >> x; v.push_back(x); } sort(v.begin(), v.end()); for(int i = N-1; i >= 0; i--){ if(v[N-1] != v[i]){ cout << v[N-1] - v[i] << endl; break; } if(i == 0){ cout << 0 << endl; break; } } return 0; }