#include#include #include #include #include #include #include using namespace std;#define N 10005#define LL long longint c[N],a[3000005];int sum(int x){ int ret=0; while(x) { ret+=c[x]; x-=x&-x; } return ret;}void add(int x){ while(x<=N) { c[x]++; x+=x&-x; }}int main(){ int n,i,j,k,l,r,m; char ch[3]; while(~scanf("%d",&n)) { memset(c,0,sizeof(c)); LL ans=0; for(i=0;i re) ans--; } a[r]=re; } } } return 0;}