Horses of chef

pls find the mistake in my solution for this problem- Contest Page | CodeChef
moreover, why is this showing Me sigterm.

include <bits/stdc++.h>

include

using namespace std;

int main()

{

int T;

int N;

cin >> T;

for (int i=1 ; i<=T ; i++)

{

    cin >> N;

    int array[N];

    for (int counter=0 ; counter < N; N++)

    {

        cin >> array[counter];

    }

    int mi= INT_MAX;

    for (int j=0 ; j<N ; j++)

    {

        for (int k=0 ; k < N ; k++)

        {

            int diff = array[j] - array[k];

            

            if (j != k)

            {

                mi = min (mi, diff) ;

            }

        }

    }

    if (mi>0)

    {

        cout << mi ;

    }

    else 

    {

        cout << -mi ;

    }



}

    

return 0;

}

#include
#include
using namespace std;
#define INT_MAX 1000000001;
int main()
{
int t;
cin>>t;
while(t–)
{
int n,b=INT_MAX;
cin>>n;
long long int a[n];
for(long long int i=0;i<n;i++)
{
cin>>a[i];
}
sort(a,a+n);
for(long long int i=0;i<n;i++)
{
for(long long int j=i+1;j<n;j++)
{
if(b>(a[j]-a[i]))
b=a[j]-a[i];
}
}
cout<<b<<endl;
}
return 0;
}