public static void main(String[] args)
  {
    if (args.length > 1)
    {
      try
      {
        int arraySize = Integer.parseInt(args[0]),
            maxValue  = Integer.parseInt(args[1]);

        if (arraySize > 0)
        {
          int array[] = new int[arraySize];

          fillWithRandomValues(array, maxValue);
          sort(array);

          for (int value : array)
            System.out.print(value + " ");

          System.out.println("");
          
          Scanner scanner = new Scanner(System.in);

          int key = 0;
          while ((key = scanner.nextInt()) > -1)
          {
            System.out.println("Found key at position: " + 
                               binarySearch(array, key, 0, arraySize - 1));
          }
        }
        else
          System.err.println("Array size can not be negative!");
      }
      catch (Exception e)
      {
        System.err.println(e);
        e.printStackTrace();
      }
    }
    else
      printHelpText();
  }