#C7064. Second Smallest Distinct Element

    ID: 50894 Type: Default 1000ms 256MiB

Second Smallest Distinct Element

Second Smallest Distinct Element

You are given an array of integers. Your task is to find the second smallest distinct element in the array. If there are fewer than two distinct elements, output Not enough elements.

Note: The numbers can be negative as well. The answer should be the second smallest after sorting the unique elements in increasing order.

Example:

  • For the array [1, 2, 3, 4, 5], the answer is 2.
  • For the array [9, 9, 9], the answer is Not enough elements.

Mathematically, if \( S \) is the set of distinct elements, and \( S = \{s_1, s_2, \ldots, s_k\} \) with \( s_1 < s_2 < \cdots < s_k \), then the answer is \( s_2 \) if \( k \geq 2 \), otherwise output Not enough elements.

inputFormat

The input is given from stdin and has the following format:

  1. The first line contains an integer T representing the number of test cases.
  2. For each test case, the first line contains an integer N denoting the number of elements in the array.
  3. The second line contains N space-separated integers.

outputFormat

For each test case, print the second smallest distinct element on a new line. If it does not exist, print Not enough elements.

The output should be written to stdout.

## sample
3
5
1 2 3 4 5
3
9 9 9
6
8 2 6 8 3 2
2

Not enough elements 3

</p>