i am stuck on a problem where, after taking input of an array and sorting it and not doing any operation on it at all, the output shows a different array?

```
#include <bits/stdc++.h>
using namespace std;

int main() {
// your code goes here
int t;
cin>>t;
while(t--){
    int n;
    cin>>n;
    long long int c[n],h[n],a[n];
    for(int i=0;i<n;i++){
        cin>>c[i];
    }
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    sort(h,h+n);
    for(int i=0;i<n;i++){
        a[i]=0;
    }
    int i=0;
    int begin=(i+1)-c[i];
    int end = (i+1)+c[i];
    int j=begin;
    while(i<n){
        a[j-1]++;
        j++;
        if(j>end){
            i++;
            begin=(i+1)-c[i];
            end= (i+1)+c[i];
            j=begin;
        }
    }

    sort(a,a+n);
    for(int i=0;i<n;i++){
        cout<<h[i]<<" ";
    }
 }
 return 0;
 }

```

input for h[]={8,8,8,8,8}..n=5
output h[]={10,10,9,9,8}