🏡 index : github.com/captn3m0/codechef.git

---
{"category_name":"easy","problem_code":"EQDIFFER","problem_name":"Equal Difference","problemComponents":{"constraints":"- $1 \\leq T \\leq 10^4$\n- $1 \\leq N \\leq 10^5$\n- $1 \\leq A_i \\leq 10^9$\n- Sum of $N$ over all test cases does not exceed $5 \\cdot 10^5$.","constraintsState":true,"subtasks":"","subtasksState":false,"inputFormat":"- The first line of input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.\n- The first line of each test case contains an integer $N$.\n- The second line of each test case contains $N$ space-separated integers $A_1, A_2, \\dots, A_N$.","inputFormatState":true,"outputFormat":"For each test case, print a single line containing one integer - the minimum number of integers to be deleted to satisfy the given condition.","outputFormatState":true,"sampleTestCases":{"0":{"id":1,"input":"3\n2\n1 2\n5\n2 5 1 2 2\n4\n1 2 1 2","output":"0\n2\n2","explanation":"**Test case $1$:** There is only one pair of integers and the absolute difference between them is $|A_1 - A_2| = |1 - 2| = 1$. So there is no need to delete any integer from the given array.\n\n**Test case $2$:** If the integers $1$ and $5$ are deleted, the array A becomes $[2, 2, 2]$ and the absolute difference between each pair of integers is $0$. There is no possible way to delete less than two integers to satisfy the given condition.","isDeleted":false}}},"video_editorial_url":"https://youtu.be/px4a4rFkh94","languages_supported":{"0":"CPP14","1":"C","2":"JAVA","3":"PYTH 3.6","4":"CPP17","5":"PYTH","6":"PYP3","7":"CS2","8":"ADA","9":"PYPY","10":"TEXT","11":"PAS fpc","12":"NODEJS","13":"RUBY","14":"PHP","15":"GO","16":"HASK","17":"TCL","18":"PERL","19":"SCALA","20":"LUA","21":"kotlin","22":"BASH","23":"JS","24":"LISP sbcl","25":"rust","26":"PAS gpc","27":"BF","28":"CLOJ","29":"R","30":"D","31":"CAML","32":"FORT","33":"ASM","34":"swift","35":"FS","36":"WSPC","37":"LISP clisp","38":"SQL","39":"SCM guile","40":"PERL6","41":"ERL","42":"CLPS","43":"ICK","44":"NICE","45":"PRLG","46":"ICON","47":"COB","48":"SCM chicken","49":"PIKE","50":"SCM qobi","51":"ST","52":"SQLQ","53":"NEM"},"max_timelimit":1,"source_sizelimit":50000,"problem_author":"soumyadeep_21","problem_tester":"","date_added":"12-07-2021","tags":{"0":"ad","1":"cook132","2":"simple","3":"soumyadeep_21"},"problem_difficulty_level":"Unavailable","best_tag":"Ad Hoc","editorial_url":"https://discuss.codechef.com/problems/EQDIFFER","time":{"view_start_date":1629658804,"submit_start_date":1629658804,"visible_start_date":1629658804,"end_date":1735669800},"is_direct_submittable":false,"problemDiscussURL":"https://discuss.codechef.com/search?q=EQDIFFER","is_proctored":false,"visitedContests":{},"layout":"problem"}
---
### Read problems statements in [Mandarin Chinese](https://www.codechef.com/download/translated/COOK132/mandarin/EQDIFFER.pdf), [Russian](https://www.codechef.com/download/translated/COOK132/russian/EQDIFFER.pdf), and [Bengali](https://www.codechef.com/download/translated/COOK132/bengali/EQDIFFER.pdf) as well.

You are given an array of $N$ integers. Find the *minimum* number of integers you need to delete from the array such that the absolute difference between each pair of integers in the remaining array will become equal.

<aside style='background: #f8f8f8;padding: 10px 15px;'><div>All submissions for this problem are available.</div></aside>