Minimize sum of points assigned to distinct elements present in an array

Minimize sum of points assigned to distinct elements present in an arrayGiven an array arr[] of size N, the task is to assign points to every distinct array element such that the sum of the points assigned is minimum possible. The following conditions are required to be satisfied while assigning points:The minimum point that can be given to a number is 1.Every distinct element should be assigned a unique value.The points should be assigned in accordance with the value of the number, i.e. smaller numbers should be assigned lower points as compared to bigger numbers.Examples: Input: N = 5, arr[] = {10, 20, 10, 25}Output: 7Explanation: Assign 1 point to 10, 2 points to 20, 3 points to 25. Sum of points = 1 + 2 + 1 + 3 = 7, which is the minimum possible.Input: N = 4, arr[] = {7, 7, 7, 7}Output: 4Explanation: Assign 1 point to 7. Sum of points = 1 + 1 + 1 + 1 = 4, which is the minimum possible.Approach: The problem can be solved greedily by assigning lower points to smaller elements. Follow the steps below to solve the problem: Initialize a variable ans as 1 to store the required result.Sort the given array in increasing order.Initialize a variable point as 1 to store the points of the current element.Iterate in the range [0, N-1] using the variable iIf arr[i] is equal to arr[i+1], then increment ans by point.Else increment the value of point by 1 and then add point to ans.Print the value of ans as the result.Below is the implementation of the above approach: C++#include using namespace std;void findMinimumSum(int arr[], int n){        sort(arr, arr + n);        int point_value = 1;        int total_points = 1;        for (int i = 0; i < n - 1; i++) {                        if (arr[i] == arr[i + 1])            total_points += point_value;                        else {            point_value = point_value + 1;            total_points += point_value;        }    }        cout