You can get good reference from book by behzad razavi(intigrate analog circuit)
in brif :
first you generate a differential current (from a diff amp section , whoes tail current source is a cascoded one)
the differential cureent is added to the cascoded output stage ("current steeling principle)
so output of the cascoded stage will give high output impedance hence you get
gain = gm*r²(where r is the outptu impedance of the cascode output stage)