Input: A = {2, 4, 1, 5, 7}
Output: 5
Explanation: During the 1st iteration, remove arr[0] and arr[2] from the array
and append their sum (2 + 1 = 3) to the end of the array.
Hence, arr[] = {4, 5, 7, 3}.
Again repeat the same process and remove arr[0] and arr[2] from the array
and now append their difference (7 - 4) = 3.
Hence, arr[] = {5, 3, 3}.
After the next iteration, array will become arr[] = {3, 8}.
And finally after the last iteration, arr[] = {5} which is the last required value.
Input: arr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
Output: 15