Average array

#include
using namespace std;

int main() {
// your code goes here
int t;
cin>>t;
while(t–){
long int n,x;
cin>>n>>x;
int arr[n];
int count = 0;
if(n==1)
cout<<nx<<endl;
else{
for(int i=0;i<n-1;i++){
arr[i] = i+1;
count += arr[i];
cout<<arr[i]<<" ";
}
cout<<n
x - count<<endl;
}
}
return 0;
}

why the my code is not passing test cases , where is it wrong