АВТ
Язык:

Дистанционный практикум по программированию

Задачи Online статус Турниры
Учебники Справка СДО
 
Здравствуйте, Гость! Войдите с паролем или зарегистрируйтесь.

1327. Race Condition

Ограничение времени: 1 сек.
Ограничение памяти:65536 КБайт
Баллы:100
Статистика Послать на проверку Задачу добавил 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

 

 


Статистика Послать на проверку Обсуждение задачи Автор/источник:
Задачи с соревнований / Чемпионат ACM / Рыбинск-2014 /
1326. B - Intellect Ltd 1327. 1328. D - Ingress 1329. E - 4x4 1330. F - Sages
 
время генерации 0.078 сек.
© Copyright ВоГУ, АВТ, Носов Д.А., Андрианов И.А.