Input: arr[] = { 2, 4, 5, 11, 6 }
Output: 1
Explanation:
Replacing a pair (arr[2], arr[3]) with their sum ( = 5 + 11 = 16) modifies arr[] to { 2, 4, 16, 16, 6 }
Since all array elements are even, the required output is 1.
Input: arr[] = { 1, 2, 4, 3, 11 }
Output: 3
Explanation:
Replacing the pair (arr[3], arr[4]) and replacing them with their sum ( = 3 + 11 = 14) modifies arr[] to { 1, 2, 4, 14, 14 }
Replacing the pair (arr[0], arr[1]) and replacing them with their sum ( = 1 + 2 = 3) modifies arr[] to { 3, 3, 4, 14, 14 }
Replacing the pair (arr[0], arr[1]) with their sum ( = 3 + 3 = 6) modifies arr[] to { 6, 6, 4, 14, 14 }.
Therefore, the required output is 3.