you give n element number 1 n element value a_i color c_i initially c_i 0 ithe follow operation apply Select element j k 1 leq j k leq n c_i c_j c_k equal 0 a_i a_k set c_j 1 find maximum value sumlimits_i1nc_i obtain apply give operation number time