why i am getting wrong ans in this problem?

#include<bits/stdc++.h>
using namespace std;
int main()
{
int i,n,t;
unsigned long int x,dif;
vectorch;
cin>>t;
while(t–)
{
cin>>n;
for(i=0;i<n;i++)
{
cin>>x;
ch.push_back(x);
}
sort(ch.begin(),ch.end());
dif=ch[1]-ch[0];
for(i=1;i<n-1;i++)
{
if(ch[i+1]-ch[i]<dif)
dif=ch[i+1]-ch[i];
}
cout<<dif<<endl;
}
return 0;
}

you are defining the vector above test cases…so for each test case the previous vector has not been erased…