Recently, it has been argued that r-process elements in galaxies primarily originate from the mergers of double neutron stars (NSs) and black hole (BH)-NS. However, there is a momentous problem that the merger timescale is estimated to be much longer than the production timescale of r-process elements inferred from metal poor stars in the Galactic halo. To solve this problem, we propose the rapid merger processes in gas-rich first-generation objects in a high redshift epoch. In such an era, it is expected that the dynamical friction by dense gas effectively promotes the merger of compact objects. To explore the possibility of mergers in a system composed of multiple NSs as well as BHs, we perform post Newtonian N-body simulations, incorporating the gas dynamical friction, the gas accretion, and the gravitational wave emission including the recoil kick. As a result, we find that NS-NS or NS-BH can merge within 10 Myr in first-generation objects. Furthermore, to satisfy the condition of the mass ejection of r-process elements, the gas accretion rate need to be lower than 0.1 Hoyle-Lyttleton accretion rate. These results imply that the mergers in early cosmic epochs may reconcile the conflict on the timescale of NS mergers.