Partial pressure of gases in alveoli
There are two main reasons for the pO2 in the alveolar air being lower than the atmospheric pO2. First, the diffusion of CO2 from the blood lowers the alveolar pO2. But the most important is the second one: there is a lot of water inside the lungs, and all this water lowers the alveolar pO2 as well.

This is the equation:

PaO2 = FiO2(Patm - PH2O) - PaCO2[FiO2 + (1-FiO2) / R] 


Source: https://en.wikipedia.org/wiki/Alveolar_gas_equation