#include #include int main(){ int n, thisDiff, minDiff, isDuplicate; std::cin >> n; std::vector a(n); std::unordered_map aCounts; for(int a_i = 0; a_i < n; a_i++){ std::cin >> a[a_i]; } std::sort(a.begin(), a.end()); minDiff = 999999; for (int i = 1; i < n; i++){ thisDiff = abs(a[i] - a[i - 1]); if (thisDiff == 0){ minDiff = 0; break; } else if (thisDiff < minDiff) minDiff = thisDiff; } std::cout << minDiff; return 0; /* isDuplicate = 0; for(int a_i = 0; a_i < n; a_i++){ std::cin >> a[a_i]; if (aCounts.find(a[a_i]) != aCounts.end()){ isDuplicate = 1; // then the abs difference is zero break; } else aCounts.insert({a[a_i], 1}); } if (isDuplicate == 1){ std::cout << 0; return 1; } // find min thisDiff = minDiff = 999999.; for (int i = 0; i < n; i++){ for (int j = i; j < n; j++){ thisDiff = abs(a[i] - a[j]); if (thisDiff < minDiff && i != j){ minDiff = thisDiff; } } } // print std::cout << minDiff; return 0;*/ }