Welcome to R2R!
The fish you mention should all be ok together in a 40B. To try to avoid territoriality, you might try to add the firefish and the goby first, then the royal gramma, then the clowns.
R2R is a great resource to learn about how to set up your first tank - everything from selecting the right parts, to getting the tank cycled and ready for fish, to help with corals and various problems that come along.
Since this is your first tank, have you checked out this forum?
https://www.reef2reef.com/forums/new-to-saltwater-reef-aquariums-post-here.130/
There is a guide to setting up a new tank that may be of interest to you:
The Supreme Guide To Setting Up A Saltwater Reef Aquarium Introduction The marine environment is one of the most complex systems on the planet. The aquarium you are about to set up is only a tiny sliver of the vast ocean, but it is nowhere near simple. This task is going to take patience, a...
www.reef2reef.com