Code not worling

hi @shriyans.singh890 u have shared code for calculate the sum question in minimum swaps to sort the array question.
ask properly

#include
#include
using namespace std;
int main() {
int x,count=0,a[100],n;
cin>>n;
for(int i=0;i<n;i++)
{
cin>>a[i];
}
for(int i=0;i<n;i++)
{
for(int j=i;j<n;j++)
{
x=INT_MAX;
if(a[j]<x)
x=a[j];
}
if(a[i]==x)
count++;
}
cout<<count;
return 0;
}

@talhashamim001 can you tell me the error in the above code