It’s type unstable. The type of a cannot be inferred, so the type of the range can’t be inferred. So all those allocations will be from unboxing and boxing while iterating over the range.
To avoid this you can put the main body of the function into a second function which accepts a itself.