Write index in elements of a array