there n child number 1 n kindergarten Kindergarten teacher give a_i 1 leq a_i leq n candy ith child Children seat row order 1 n leave right start eat candy while ith child eat candy calculate number l_i r_i number child seat leave get candy number child seat right get candy respectivelyformally l_i number indice j 1 leq j a_i a_j r_i number indice j j leq n a_i a_jEach child tell kindergarten teacher number l_i r_i calculate unfortunately forgot candy give child so ask help give array l r determine give candy child child correctly calculate value l_i r_i definitely mistake if possible find way