Collective long-range particle correlation in proton-proton and proton-nucleus collisions at the LHC with the CMS detector