Hey, fellow programmers. Hope you all are doing good.I don't want to waste your precious time so let's cut to the chase. As you can see I'm a newbie so pardon me if what i ask is way above my league. Believe me I'm trying but this competitive programming is difficult for me but sooner or later i will become good at this.

This was one of the questions asked in Amazon Hackathon round please help me solve this. Since I'm a newbie you can also share the links to article and knowledge resources that might be required to solve this. Please do not provide code directly as answer. Let me know how to solve and approach this problem.

The question is as follows-

/*****************************************

You are given N non negative integers namely-D1,D2,D3...DN. You have to find all the labelled trees that can be constructed such that the out-degrees of each vertex(1<=i<=N) is Dn. It is guaranteed that the sum of D1,D2....Dn is N-1.

Example test case- First line is number of integer and second line contains degree of each edges. Input- 4 0 1 0 2

Output- 5

A total of 5 labelled trees can be formed with given out-degrees.

Input-

5 0 1 1 1 1

Output- 125

A total of 125 labelled trees can be formed with given out-degrees. *************************************************************/