import java.util.*;

public class RandomTiming
{
   public static void randomPermutation(int[] a)
   {
      //einen neuen Zufallszahlengenerator anlegen
      Random gen = new Random();

      for(int i = a.length-1; i > 0; i--)
      {
         //Element fuer Position i zufaellig waehlen
         int p = gen.nextInt(i+1);
         
         //Elemente an Positionen p und i tauschen
         int h = a[i];
         a[i]  = a[p];
         a[p]  = h;
      }
   }

   public static void fillArray(int[] a)
   {
      for(int i = 0; i < a.length; i++){a[i] = i;}
   }

   public static void main(String[] args)
   {
      int[] folge = new int[Integer.parseInt(args[0])];
      
      fillArray(folge);

      long start = System.currentTimeMillis();
      randomPermutation(folge);
      long ende = System.currentTimeMillis();

      long dauer = ende - start;

      System.out.println("Das Permutieren hat " + dauer + " Millisekunden gedauert");
   }
}
