  The composition of the overall spectrum of cosmic rays (CRs) is studied under
the assumption that ultra high energy CRs above the energy 10^{17} eV are
produced at the shock created by the expanding cocoons around active galactic
nuclei (AGNs). It is shown that the expected CR composition is characterised by
two peaks in the energy dependence of the mean CR atomic number <A(\epsilon)>.
The first one at the energy \epsilon \approx 10^{17} eV corresponds to the very
end of the Galactic CR component, produced in supernova remnants (SNRs). It is
followed by a sharp decrease of <A(\epsilon)> within the energy interval from
10^{17} to 10^{18} eV. This is a signature of the transition from Galactic to
extragalactic CRs. The second peak, with <ln A> \approx 2, at energy
\epsilon\approx 10^{19} eV, expected at the beginning of the GZK cutoff, is the
signature of the CR production by the nonrelativistic cocoon shocks. The
calculated CR composition is consistent with the existing data. The alternative
scenario, which suggests reacceleration increasing the energy of CRs produced
in SNRs by a factor of 30, is also examined.
