title: Minimum Increment K Operations Make Elements Equal
signature: minimum_increment_k_operations_make_elements_equal <- function(arr, n, k) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(arr, n, k, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(arr, n, k), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          list(4L, 7L, 19L, 16L), 4L, 3L, 
          10L
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          list(4L, 4L, 4L, 4L, 4L), 5L, 3L, 
          0L
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          list(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), 39L, 1L, 
          24L
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          list(85L, 36L, 52L, 8L, 52L, 15L, 16L), 5L, 6L, 
          -1L
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          list(-10L, -5L, -5L, -20L, 10L, 30L), 6L, 5L, 
          36L
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          list(0L, 1L, 0L, 0L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 1L, 1L, 0L, 0L, 1L, 0L), 10L, 15L, 
          -1L
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          list(1L, 5L, 5L, 9L, 11L, 12L, 12L, 13L, 13L, 14L, 16L, 18L, 26L, 26L, 28L, 28L, 30L, 31L, 32L, 37L, 37L, 38L, 40L, 43L, 44L, 45L, 47L, 47L, 55L, 58L, 60L, 62L, 63L, 64L, 69L, 78L, 83L, 84L, 92L, 96L, 96L, 99L), 26L, 33L, 
          -1L
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          list(76L, -78L, 92L, -98L, 16L, 44L, 86L, 96L, -8L, 2L, -96L, 74L, -28L, 12L, 54L, -40L, -64L, -12L, 4L, 48L, 68L, -82L, 8L, 0L, -4L, 88L, 48L, -54L, 90L, 62L, -84L, 76L, -48L, 62L, -80L, -94L, 38L, -4L, 36L), 34L, 3L, 
          -1L
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          list(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), 39L, 10L, 
          -1L
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          list(62L, 99L, 29L, 23L, 55L, 30L, 79L, 63L, 1L, 88L, 59L, 8L, 11L, 80L, 23L, 51L, 97L, 32L, 80L, 48L, 84L, 36L, 73L, 59L, 1L, 34L, 92L, 10L), 18L, 1L, 
          892L
      )))
  
  }
  
  main()
source_py: def minimum_increment_k_operations_make_elements_equal(arr, n, k):
      max1 = max(arr)
      res = 0
      for i in range(0, n):
          if (((max1 - arr[i]) % k) != 0):
              return (- 1)
          else:
              res += ((max1 - arr[i]) / k)
      return int(res)
source_cpp: int minimum_increment_k_operations_make_elements_equal(vector<int> arr, int n, int k) {
    int max = * max_element(arr.begin(), arr.end());
    int res = 0;
    for ( int i = 0;
    i < n;
    i ++ ) {
      if ( ( max - arr [ i ] ) % k != 0 ) return - 1;
      else res += ( max - arr [ i ] ) / k;
    }
    return res;
  }