It was well within the 300 km operational range of an S-200D system, which is what Ukraine said it shot it with.
I know the memes about Russian incompetence, and I know Russia itself prefers to blame friendly fire rather than admitting that they were beaten by those that they consider to be subhuman vermin, but the friendly fire excuse does not make sense. The A-50 is a very big, very easily identifiable target, that flies on a very regular, very predictable trajectory. To shoot it down with friendly fire requires not mere incompetence, but actual treachery.
In this case, Russian incompetence was in not taking the S-200D risk into account, as well as a failure to use what evasive maneuvers were available to the A-50 (if you look at the footage, you can see it was flying in a straight line dropping flares (and probably chaff, but that wasn't visible in the night sky). It wasn't diving down to try to disappear into the ground clutter and cause the missile to lose more energy to air friction.
One interesting thing to note about the whole A-50 shoot down is that it was the logical outcome of a long campaign to defeat Russia in the sky. It started with the campaign to defeat Russia in the sea. Sinking the Moskva (an air defense ship) and pushing the Black Sea fleet away from Snake Island and Kherson/Odessa area allowed Ukraine special forces to take control of the oil towers and remove Russian radars from them. Then Russia was blind to threats coming from the West of Crimea. Lots of missile raids then happened on Crimea's radar stations and air defense systems. The damage to the static and road-mobile systems was so extensive that Russia had to bring in the A-50, but then they lost two of those.
All these losses have crippled their ability to watch the Ukrainian skies and look out for Ukrainian SAMs. And so Ukraine is on the verge of obtaining air superiority thanks to clever tactics and meticulous planning. Note however that I'm not taking about air supremacy; obtaining that is going to need more than tactic and planning.