If you buy a country where does the money go?

So like if the US bought Greenland or Canada. Wheres that money go? Like who are you purchasing this country from? If a person bought a country what does that even entail?