text: # Distinct Values Codechef Solution
  
  ### We Are Discuss About CODECHEF SOLUTION
  
  Distinct Values Codechef Solution
  
  ## Problem
  
  The beauty value of an array is defined as the difference between the largest and second largest elements of the array. Note that the largest and second largest elements can have the same value in case of duplicates.
  
  For example, beauty value of [2,5,3,1]=5−3=2 and beauty value of [7,6,7]=7−7=0
  
  You are given an array  of length . Your task is to find the total number of distinct beauty values among all subarrays of  having length greater than 1.
  
  Note that, a subarray is obtained by deleting some (possibly zero) elements from the beginning and some (possibly zero) elements from the end of the array.
  
  ### Input Format
  
  • The first line of input will contain a single integer , denoting the number of test cases.
  • Each test case consists of two lines of input.
  • The first line of each test case contains a single integer  — the size of the array.
  • The second line contains  space-separated numbers – �1,�2,…,��, the elements of the array.
  
  ### Output Format
  
  For each test case, output a single line, the total number of distinct beauty among all subarrays of  having length greater than 1.
  
  ### Constraints
  
  • 1≤�≤104
  • 2≤�≤2⋅105
  • 1≤��≤109
  • Sum of  over all test cases does not exceed 2⋅105.
  
  ### Sample 1:
  
  Input
  
  Output
  
  4
  2
  1 1
  3
  4 2 1
  4
  8 1 7 2
  5
  6 9 4 2 1
  
  1
  2
  4
  4
  
  ### Explanation:
  
  Test case 1: The only subarray is [1,1] whose beauty is 0. Thus, there is only 1 distinct value of beauty.
  
  Test case 2: The subarrays are [4,2],[2,1], and [4,2,1] having beauty 2,1, and 2 respectively. There are 2 distinct values of beauty.
  
  Test case 3: The unique values of beauty are 7,1,6, and 5.
  
  Test case 4: The unique values of beauty are 3,5,2, and 1.
  
  ## SOLUTION
  
  Yhaa You have done it but next? if YOU Want to Get Others Please Visit Here ScishowEngineer   Then Follow US HERE and Join Telegram.
explanation: The provided text is a problem statement and solution for a coding challenge from CodeChef. It describes a problem where the goal is to find the total number of distinct "beauty" values among all subarrays of a given array, where the "beauty" value is defined as the difference between the largest and second largest elements in the subarray. The text includes an input format, output format, constraints, and a sample input with corresponding output and explanations.
  
  The text does not contain a direct math question or a question-and-answer pair. It is primarily a problem statement and solution for a programming challenge.
distilabel_metadata.content: Evaluate the user given text extract and determine if it contains a math question and optionally and answer to this question.
  
  Output rules:
  
  1. Briefly describe the document and mention if it contains a question or a question and answer.
  2. Finalize the output with: Label: no-question,question,question-and-answer,multiple-question,multiple-question-and-answer
distilabel_metadata.role: system
distilabel_metadata.content: # Distinct Values Codechef Solution
  
  ### We Are Discuss About CODECHEF SOLUTION
  
  Distinct Values Codechef Solution
  
  ## Problem
  
  The beauty value of an array is defined as the difference between the largest and second largest elements of the array. Note that the largest and second largest elements can have the same value in case of duplicates.
  
  For example, beauty value of [2,5,3,1]=5−3=2 and beauty value of [7,6,7]=7−7=0
  
  You are given an array  of length . Your task is to find the total number of distinct beauty values among all subarrays of  having length greater than 1.
  
  Note that, a subarray is obtained by deleting some (possibly zero) elements from the beginning and some (possibly zero) elements from the end of the array.
  
  ### Input Format
  
  • The first line of input will contain a single integer , denoting the number of test cases.
  • Each test case consists of two lines of input.
  • The first line of each test case contains a single integer  — the size of the array.
  • The second line contains  space-separated numbers – �1,�2,…,��, the elements of the array.
  
  ### Output Format
  
  For each test case, output a single line, the total number of distinct beauty among all subarrays of  having length greater than 1.
  
  ### Constraints
  
  • 1≤�≤104
  • 2≤�≤2⋅105
  • 1≤��≤109
  • Sum of  over all test cases does not exceed 2⋅105.
  
  ### Sample 1:
  
  Input
  
  Output
  
  4
  2
  1 1
  3
  4 2 1
  4
  8 1 7 2
  5
  6 9 4 2 1
  
  1
  2
  4
  4
  
  ### Explanation:
  
  Test case 1: The only subarray is [1,1] whose beauty is 0. Thus, there is only 1 distinct value of beauty.
  
  Test case 2: The subarrays are [4,2],[2,1], and [4,2,1] having beauty 2,1, and 2 respectively. There are 2 distinct values of beauty.
  
  Test case 3: The unique values of beauty are 7,1,6, and 5.
  
  Test case 4: The unique values of beauty are 3,5,2, and 1.
  
  ## SOLUTION
  
  Yhaa You have done it but next? if YOU Want to Get Others Please Visit Here ScishowEngineer   Then Follow US HERE and Join Telegram.
distilabel_metadata.role: user
distilabel_metadata.raw_output_q_a_detector_0: The provided text is a problem statement and solution for a coding challenge from CodeChef. It describes a problem where the goal is to find the total number of distinct "beauty" values among all subarrays of a given array, where the "beauty" value is defined as the difference between the largest and second largest elements in the subarray. The text includes an input format, output format, constraints, and a sample input with corresponding output and explanations.
  
  The text does not contain a direct math question or a question-and-answer pair. It is primarily a problem statement and solution for a programming challenge.
  
  Label: no-question