Handing out candies

For every K, count the ways to choose one candy of each brand 1 through K, and print the total over all K.

Medium5Dynamic programmingCombinatoricsInterviewNo attempts yetTime limit2sMemory limit512 MB

Problem

You want to hand out candies to the participants of an algorithm camp.

You have NN candies, and every candy has a brand written as an integer.

First you decide KK, the number of candies you hand out. Then you pick exactly one candy of each brand from brand 11 through brand KK.

KK can be any value from 11 to NN, and two candies of the same brand count as different candies. Write a program that computes the total number of ways to pick the candies, summed over every KK.

Input

The first line contains the number of candies NN. (1N501 \le N \le 50)

The second line contains the brands of the NN candies, separated by spaces. Each brand is an integer between 11 and 5050.

Output

Print the number of ways to pick the candies on the first line. The value is smaller than 2312^{31}.