{"problem":{"name":"J. Smallest Difference","description":{"content":"You are given an array a consists of n elements, find the maximum number of elements you can select from the array such that the absolute difference between any two of the chosen elements is  ≤ 1. Th","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":1000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF10185J"},"statements":[{"statement_type":"Markdown","content":"You are given an array a consists of n elements, find the maximum number of elements you can select from the array such that the absolute difference between any two of the chosen elements is  ≤ 1.\n\nThe first line contains an integer T (1 ≤ T ≤ 100), in which T is the number of test cases.\n\nThe first line of each test case consist of an integer n (2 ≤ n ≤ 104), in which n is size of the array a\n\nThe a line follow containing n elements a1, a2, ..., an (1 ≤ ai ≤ 104), giving the array a.\n\nFor each test case, print a single line containing the maximum number of elements you can select from the array such that the absolute difference between any two of the chosen elements is  ≤ 1.\n\n## Input\n\nThe first line contains an integer T (1 ≤ T ≤ 100), in which T is the number of test cases.The first line of each test case consist of an integer n (2 ≤ n ≤ 104), in which n is size of the array aThe a line follow containing n elements a1, a2, ..., an (1 ≤ ai ≤ 104), giving the array a.\n\n## Output\n\nFor each test case, print a single line containing the maximum number of elements you can select from the array such that the absolute difference between any two of the chosen elements is  ≤ 1.\n\n[samples]","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ n \\in \\mathbb{Z} $ be the number of cadets.  \nLet $ S = (s_1, s_2, \\dots, s_n) $ be the sequence of scores, where $ s_i $ is the score of the $ i $-th cadet (in finishing order).\n\n**Constraints**  \n1. $ 1 \\leq n \\leq 10^5 $  \n2. $ 0 \\leq s_i \\leq 10^6 $ for all $ i \\in \\{1, \\dots, n\\} $\n\n**Objective**  \nFor each cadet $ i \\in \\{1, \\dots, n\\} $, compute the grade $ g_i $ as:  \n$$\ng_i = n - \\left| \\left\\{ j \\in \\{1, \\dots, i-1\\} \\mid s_j \\geq s_i \\right\\} \\right|\n$$","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF10185J","tags":[],"sample_group":[],"created_at":"2026-03-03 11:00:39"}}