So a large team like Ferrari or McLaren will spend about $400 million on running the whole team for the year - that includes all salaries, R&D, simulation, transport, part costs, marketing etc.
They'll get about $80 million back on that from prize money (it's more like $100 million if you win).
Then there's the sponsorship - for a large team about $300 million a year is reasonable.
The rest can often be found from elsewhere. McLaren had large funding from Daimler until recently (when they received a $40 million fine Daimler paid) - Ferrari have a lot of their own money. F1 drives car sales, and the technology from F1 can be pulled back into the road cars - just look at McLaren's new models..