#C8802. Minimal Transformations
Minimal Transformations
Minimal Transformations
You are given an array of positive integers. For each integer n in the array, you must apply the following transformation repeatedly until n becomes 1:
- If n is even, then \( n = \frac{n}{2} \).
- If n is odd, then \( n = \left\lfloor \frac{n}{2} \right\rfloor + 1 \).
The number of times you perform the transformation on an integer is called its transformation count. Your task is to determine the integer from the array that requires the smallest number of transformations to reach 1. If there are multiple such integers, choose the one that appears first in the array.
inputFormat
The input is given via stdin:
- The first line contains a single integer \( n \) (\( 1 \leq n \leq 10^5 \)) — the number of elements in the array.
- The second line contains \( n \) space-separated positive integers.
outputFormat
Print a single integer — the element that requires the smallest number of transformations to reach 1. The output should be written to stdout.
## sample3
2 7 3
2
</p>