fork download
  1. //Bai 21
  2.  
  3. #include<bits/stdc++.h>
  4. using namespace std;
  5. #define el "\n"
  6. #define ll long long
  7. #define ull unsigned long long
  8. #define se second
  9. #define fi first
  10. #define be begin()
  11. #define en end()
  12. #define Faster cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
  13. int n;
  14. void Run()
  15. {
  16. cin >> n;
  17. ll a[n];
  18. for(auto &x : a) cin >> x;
  19. sort(a, a + n);
  20. ll ans = abs(a[1] - a[0]);
  21. for(int i = 2; i < n; i++) ans = min(ans, a[i] - a[i - 1]);
  22. cout << ans;
  23. }
  24. int main()
  25. {
  26. Faster;
  27. Run();
  28. return 0;
  29. }
  30.  
  31.  
Success #stdin #stdout 0s 5284KB
stdin
Standard input is empty
stdout
8364328522465880860