Please someone explain the second case or subtask and what is the use of that formula in the editorial sol