Otherwise get the value from the map and update right [ i ]
else : NEW_LINE INDENT tmp = map [ arr [ i ] ] ; NEW_LINE right [ i ] = ( tmp . count ) * ( abs ( i - tmp . prevIndex ) ) + right [ tmp . prevIndex ] ; NEW_LINE map [ arr [ i ] ] = pair ( tmp . count + 1 , i ) ; NEW_LINE DEDENT