You will need to do modular arithmetic to determine indices based on ranks.