Bash Array Change
array_change() {
local -n _a="$1"
local _min=0 _k _c=${#_a[@]}
for ((_k = 0; _k < _c - 1; _k++)); do
if (( _a[_k] >= _a[_k+1] )); then
local _dif=$(( _a[_k] - _a[_k+1] + 1 ))
_a[_k+1]=$(( _a[_k+1] + _dif ))
_min=$(( _min + _dif ))
fi
done
echo "$_min"
}
This moves left to right and bumps values only when needed so the array becomes strictly increasing.