suppose i have a vector containing n elements. I want to find out the number of previous elements greater than its element at present index i . I mean i want to find A(i)>A(j) && i

constraints : 1<=t <=1000 , 1<=n <=10^5 , 1<=A(i)<=10^5

My code:

```
#include<bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
while(t--)
{
int n,a,i,j;
cin >> n;
vector<int>v1;
for(i=0;i<n;i++)
{
cin >> a;
v1.push_back(a);
}
int cnt=0,sum=0;
for(i=0;i<n;i++)
{
if( i!=0)
{
for(j=0;j<i;j++)
{
if(v1(i)<v1(j))
{
cnt++;
}
}
}
// cout << cnt << " ";
sum=sum+cnt;
cnt=0;
}
cout << sum << 'n';
}
}
```

This code is running fine for all the test cases except only one. It is showing the Time limit exceeded for one of the test cases.Can anyone help me?