ÀÂÒ
Language: Russian
English

Remote Training on Programming

Problems Online status Contests
News FAQ E-learning
For authors:
Register  ||  Login
 
Hello, Guest! Please login or register.

1327. Race Condition

Time Limit: 1 seconds
Memory Limit:65536KB
Points:100
View Problem Statistics Submit Problem added debug

Vasya has written a program that launches n threads having mi instructions each.

At any point in time the CPU is executing a single instruction from a single thread. The instructions in a thread are always executed in order (switching to other threads is possible).

After all instructions in a thread have been executed, the CPU ignores this thread.

Let us define an execution path as an ordered list of actually executed instructions from different threads.

Write a program to calculate the number of different execution paths (accounting for all possible switches between threads) for a multi-threaded program.

Limitations

1≤ n ≤ 10; 1 ≤ mi  ≤ 20, 1≤ in, .

 

Input

The first line of the input file defines the number of threads n.

The second line contains n space-delimited integers mi, the number of instructions in the threads.

Output

The number of different execution paths.

Input

Output

2

2 2

6

3

1 2 3

60

 

 


View Problem Statistics Submit Problem discussion Author/source:
Problems from Contests and Camps / World Championship in Programming (ICPC) / Rybinsk-2014 /
1326. B - Intellect Ltd 1327. 1328. D - Ingress 1329. E - 4x4 1330. F - Sages
time generating 0.453 sec.
© Copyright VSU, AVT, Nosov D.A., Andrianov I.A.