One enters on Day 1 One, leaves on Day 40, so 40 days spent of the 90 days.
One then re-enters on day 200 at which point one looks back 180 days and finds only the last 20 days of the first 40 are in the 180 backtrack. At that point one has a used only 20 days in the first entry of 40 days so one can stay 70 more days, i.e. to Day 270
At day 220 the first entry of the whole 40 days have expired from the rolling 180 days, so one can stay the balance of 90 days less the 20 days from the second entry at Day 200, so a further 70 days to Day 290.
So one has been absent fom Day 40 to Day 200 = 160 days and one can be present from Day 1 to Day 290 = 290 days with 160 days absent, a net 130 days in 290 days in Schengen.