Pair the integers of Array so that each pair sum is consecutive and distinct
Given an array arrof size N. We have to pair the integers such that each integer should be in exactly one pair and each sum of pairs is consecutive and distinct. Formally, sum(arri + arrj) + 1 = sum(arri1 + arrj1). Print the pairs of integers satisfying all the conditions. If it is not possible to find the pairs return -1.Examples:Input: N = 6, arr = {2, 3, 1, 4, 6, 5}Output:1 6 3 54 2Explanation: All pair’s sum is consecutive.Input: N = 8 arr = {8, 7, 1, 2, 3, 5, 6, 4}Output: -1Approach: This can be solved with the…