No tags yet

No tag edit access

time limit per test: 0.25 sec.

memory limit per test: 4096 KB

memory limit per test: 4096 KB

input: standard input

output: standard output

output: standard output

Smith has N chains. Each chain is the sequence of successively connected links. The length of each chain is known: the first chain contains L1 links, the second - L2, ..., the last one - LN.

He can make a following series of actions in a minute:

1. to unchain one link

2. to remove or to put into the unchained link some other links of any chain

3. to chain the link

Your task is to determine the minimum time which will take the smith to connect all the chains in one line, i.e. the chain will look like a chain made up of successively connected links.

He can make a following series of actions in a minute:

1. to unchain one link

2. to remove or to put into the unchained link some other links of any chain

3. to chain the link

Your task is to determine the minimum time which will take the smith to connect all the chains in one line, i.e. the chain will look like a chain made up of successively connected links.

The first line contains natural number N<=100. The second line contains L1, L2, ..., LN (1<=Li<=100, for all i = 1..N).

Output the only integer number - the solution to the problem.

Input

2

3 4

3 4

Output

1

Author: | Michael R. Mirzayanov |

Resource: | ACM International Collegiate Programming Contest 2003-2004 North-Eastern European Region, Southern Subregion |

Date: | 2003 October, 9 |

Codeforces (c) Copyright 2010-2019 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Oct/18/2019 20:33:57 (e1).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|