40 minutes! OMG, I wouldn't it.
I did twice ex-OSL, both times I stayed overnight in either Radisson Blu or Red the night before.
I'd ditch transit in MAD and save 1 segment. I think if you have OSL-DOH-SIN, AA RTW desk will ticket for you if you have 1 long haul flight on AA metal.
Just my 2 cents