// CS301.01 Spring 2k Drivers: Humaa & Patrick Backseat Drivers: John, Andrew(2), Rachel Engineered by kbg 

#include<iostream>
#include<vector>
#include<time.h>

//Function:Check Sort 

bool CheckSort(vector<int> & a)
{ vector<int>::iterator j;
  for (j=a.begin(); j != a.end()-1; j++)
  { 
    if (*j > *(j+1))
       return false; 
  }
  return true;
}

void Transpose(vector<int> & a)
{
   unsigned long int  i, j, temp;
   
   i = (int) random() % a.size();
   j = (int) random() % a.size();
   temp = a[i];
   a[i] = a[j];
   a[j] = temp;
}

main ( int argc, char* argv[])
{
  int size= atoi (argv[1]);
  vector < int > a (size);
  srandom(time((time_t*)0));
  int i;

  for(i=0;i<size; i++){
    a[i] =(int) random ();
    //    cout << a[i] << endl;
      } 

  int Count=0;

  while(!CheckSort(a)){
    Transpose(a);
    Count++;
  }

  cout << Count << endl;  
}





