<gouthampradhan>array_MinimumMovesToEqualArray_1.java
public int minMoves2(int[] nums) {
    if (nums.length == 1) return 0;
    else if (nums.length == 2) return Math.abs(nums[0] - nums[1]);
    Arrays.sort(nums);
    int median;
    if ((nums.length % 2) == 1) {
      median = (nums.length / 2);
      int sum = 0;
      for (int i = 0; i < nums.length; i++) {
        sum += Math.abs(nums[i] - nums[median]);
      }
      return sum;
    } else {
      median = (nums.length / 2) - 1;
      int sum = 0;
      int min;
      for (int i = 0; i < nums.length; i++) {
        sum += Math.abs(nums[i] - nums[median]);
      }
      min = sum;
      sum = 0;
      median = (nums.length / 2);
      for (int i = 0; i < nums.length; i++) {
        sum += Math.abs(nums[i] - nums[median]);
      }
      min = Math.min(min, sum);
      return min;
    }
  }
public int sample_funcname ( int [ ] var_0 ) {
  if ( var_0 . length == 1 ) return 0 ;
  else if ( var_0 . length == 2 ) return Math . abs ( var_0 [ 0 ] - var_0 [ 1 ] ) ;
  Arrays . sort ( var_0 ) ;
  int var_9 ;
  if ( ( var_0 . length % 2 ) == 1 ) {
    var_9 = ( var_0 . length / 2 ) ;
    int var_10 = 0 ;
    for ( int var_11 = 0 ;
    var_11 < var_0 . length ;
    var_11 ++ ) {
      var_10 += Math . abs ( var_0 [ var_11 ] - var_0 [ var_9 ] ) ;
    }
    return var_10 ;
  }
  else {
    var_9 = ( var_0 . length / 2 ) - 1 ;
    int var_10 = 0 ;
    int min ;
    for ( int var_11 = 0 ;
    var_11 < var_0 . length ;
    var_11 ++ ) {
      var_10 += Math . abs ( var_0 [ var_11 ] - var_0 [ var_9 ] ) ;
    }
    min = var_10 ;
    var_10 = 0 ;
    var_9 = ( var_0 . length / 2 ) ;
    for ( int var_11 = 0 ;
    var_11 < var_0 . length ;
    var_11 ++ ) {
      var_10 += Math . abs ( var_0 [ var_11 ] - var_0 [ var_9 ] ) ;
    }
    min = Math . min ( min , var_10 ) ;
    return min ;
  }
}
