Optimal design of a distributed network with a two-level hierarchical structure