Average an array until all numbers are (almost) equal
Perl 6,  83  82 bytes

-&gt;\a(\b,|c){(c,{[(b,|$_,b).rotor(3=&gt;-2).map: *.sum/3]}...{(b+.sum)/a~~b-1..b+1})-1}


Try it

-&gt;\a(\b,|c){(c,{[(b,|$_,b).rotor(3=&gt;-2).map: *.sum/3]}...{1&gt;abs (b+.sum)/a -b})-1}


Try it (also works for complex numbers

Expanded

-&gt;      # pointy block lambda

  \a    # the input array
  (
    \b, # the first value  
    |c  # all the rest of the values
  )

{
  (
    # generate a sequence

    c,                 # initialize the sequence starting with the second value

    {                  # bare block lambda with implicit parameter ｢$_｣

      [                # turn the result from a Seq into an array

        ( b, |$_, b )  # re-add the first element
                       # and add it to the end

        .rotor(3=&gt;-2)  # grab 3 at a time, backing up 2

        .map: *.sum/3  # return the average for each sub sequence

      ]
    }

    ...                # keep calling that to generate values until

    {
      1 &gt; abs ( b + .sum )/a - b     # they are almost equal
    }

  ) - 1 # count them and reduce by one (ignore initial value)
}