#include #include int main() { int b,i,cnt=0,s=0,t,k,j=0; int* a; scanf("%d\n",&i); a=(int *)malloc( sizeof(int)*i+1); for(b=1;b<=i;b++){ scanf(" %d",&a[b]); } while(j==0){ for(b=1;ba[b+1]){ break; } if(b==i-1)j=-1; } if(j!=-1){ for(b=2;b<=i;b++){ if(a[b]s){ s=a[b]; t=b; } } for(b=t;b>1;b--){ a[t]=a[t-1]; } a[1]=s; s=0; cnt++; } } free(a); printf("%d\n",cnt); return 0; }