RP = $\frac{λ}{dλ}$ = nN
For wavelengths 5140.34 & 5140.85 Å……..
Mean wavelength λ is $\frac{5140.34 + 5140.85}{2} = 5140.595 \ A° $
Smallest difference between them is 5140.85 – 5140.34 = 0.51 A°
First order, n=1
$ N= \frac{1}{n} \times \frac{λ}{dλ} = \frac{1}{1} \times \frac{5140.595}{0.51} = 10080 $
The RP $\frac{λ}{dλ}$ of a grating in second oder should be nN = 2x10080 = 20160
In this case λ is $\frac{8037.20 + 8037.50}{2} = 8037.35 \ A° $
Smallest difference between them is 8037.20 - 8037.50 = 0.30 A°
RP = $\frac{8037.35}{0.30}$ = 26791.17
So the grating will not be able to resolve the lines 8037.20 & 8037.5 AU in second order because the required RP is 26791 is greater than actual RP is 20160.