title: increment numbers in an array until they are all equal
body: <p>The goal of this program is to make all numbers in an array the same. You have to increment all values in the array except for one each time. Then the program will print out the minimum number of steps it would take to make all the numbers the same. I have what I believe is a working solution I just want to make it more efficient, does any one have any ideas? In the following code the user enters the initial values for the numbers into the array and then calculates the amount of steps required</p>
  
  <pre><code>public static void main(String[] args) throws NumberFormatException, IOException 
  {
  counter=0;
           size=sc.nextInt();
           input= new int[size];
          for(int k=0; k&lt;size; k++)
          {
              input[k]=sc.nextInt();
          }
          while(!isAllEqual(input))
          {
              Arrays.sort(input);
              for(int k=0; k&lt;input.length-1; k++)
              {
                  input[k]++;
              }
              counter++;
          }
          pw.println(counter);
  
  public static boolean isAllEqual(int[] a){
      for(int i=1; i&lt;a.length; i++){
          if(a[0] != a[i]){
              return false;
          }
      }
  return true;
  }
  </code></pre>