Fix bug of sum of ranks