To keep the pressure constant, air has to be expelled, i.e. number of moles decreases. Note that the volume of the flask is also constant!
n1=n, T1=300 K, T2=400 K, n2=?
At constant pressure and volume n1T1=n2T2
∴n2=n1T1T2=n×300400=3n4
∴ amount of air escaped = initial moles - final moles =n4
∴% air escaped =n4n×100=25%