Get index of last inserted element in array