Otherwise get the value from the map and update right [ i ]
else { pairr * tmp = mapp [ arr [ i ] ] ; right [ i ] = ( tmp -> count ) * ( abs ( i - tmp -> prevIndex ) ) + right [ tmp -> prevIndex ] ; mapp [ arr [ i ] ] = new pairr ( tmp -> count + 1 , i ) ; } }