fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. typedef long long LL;
  6.  
  7. int main()
  8. {
  9. LL N, tmp, sum = 0, a = 1000001, b = 0;
  10. cin >> N;
  11. for (int i = 0; i < N; ++i) {
  12. cin >> tmp;
  13. a = min(a,tmp);
  14. b = max(b, tmp);
  15. }
  16. cout << (b-a+1 - N);
  17.  
  18. return 0;
  19. }
  20.  
Success #stdin #stdout 0s 3416KB
stdin
3
5
2
3
stdout
1