Help me in solving ONEFROMK problem

My issue

My code

#include <iostream>
using namespace std;

int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--){
	    int n;
	    cin>>n;
	    int A[n];
	    for(int i=0;i<n;i++){
	        cin>>A[i];
	    }
	    int score=0;
	    for(int i=k;i<=n;i++){
	        
	    }
	}
	return 0;
}

Problem Link: ONEFROMK Problem - CodeChef

@aayushmanpatha
The logic is quite simple just sum up all the values of the array and then sort the array and for each index subtract the value like 2 3 1 4
first print the sum = 10;
then sort 1 2 3 4
then print like sum-1,sum-1-2,sum-1-2-3…so on