Bhalladeva is giving wrong answer

I want to know in which case my code is failing.

Below is the link to the question:

Below is the code:

#include<iostream>
#include<cstdio>
#include<algorithm>
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);


using namespace std;

int main()
{
	FAST_IO
unsigned long int N,Q,K,sum=0;
cin>>N;
unsigned long int A[N],A_K[N];

for(unsigned long int i=0;i<N;i++)
	cin>>A[i];
	
sort(A,A+N);

for(unsigned long int j=0;j<N;j++)
		{
			sum=sum+A[j];
			A_K[j]=sum;
		}


cin>>Q;

for(unsigned long int i=0;i<Q;i++)
{
	cin>>K;
    cout<<A_K[N-K-1]<<"\n";
}

    return 0;
}

Hey,
While printing out the answer the array index should be [N/(K+1)-1] and not [N-K-1]. You can have a look at my solution for reference https://www.codechef.com/viewsolution/28565479
This is because we can acquire K+1 coins for the cost of 1 coin and hence for N coins we have to pay N/(K+1) coins.