<|instruction|>
Solve the below problem. The solution should start with an abridged problem statement. Then key observations. Then full solution based on the observations. Then C++ and Python implementations with comments.

186. The Chain
time limit per test: 0.25 sec.
memory limit per test: 4096 KB
input: standard input
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.

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

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

Sample test(s)

Input
2
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

<|response|>
1. Abridged Problem Statement  
   You have N separate chains, where the i-th chain has Li links. In one minute, you can open exactly one link, use that open link to connect two chains (by hooking one chain onto the open link), and then close it. What is the minimum number of minutes required to join all N chains into a single continuous chain?

2. Key Observations  
   • To reduce the number of separate chains from N down to 1, you must perform exactly N–1 “merge” operations (each merge connects two chains into one).  
   • Each merge takes exactly one minute (you open one link, hook another chain, then close it).  
   • Since every chain has at least one link (Li ≥ 1), you will always have enough links available to perform all N–1 merges.  
   ⇒ Therefore, the answer is simply N – 1, regardless of the individual Li.

3. Full Solution Approach  
   1. Read N (the number of chains).  
   2. Read the sequence L1…LN (the chain lengths).  
   3. Observe that we need N–1 connection operations and each costs 1 minute.  
   4. Print N–1.  
   This runs in O(N) time (just to read the input) and uses O(N) memory for reading L, but the lengths themselves do not affect the result.

4. C++ Implementation with Detailed Comments  
```cpp
#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N;
    cin >> N;

    // Read the lengths, though they do not affect the answer in this problem
    for (int i = 0; i < N; i++) {
        int Li;
        cin >> Li;
    }

    // To connect N chains into one, we need exactly N-1 merges,
    // each taking one minute.
    int result = max(0, N - 1);

    cout << result << "\n";
    return 0;
}
```

5. Python Implementation with Detailed Comments  
```python
import sys

def main():
    data = sys.stdin.read().split()
    n = int(data[0])
    # The next n integers are the chain lengths, which we do not actually need
    # for computing the minimal time, since every Li >= 1 guarantees enough links.
    # lengths = list(map(int, data[1:]))

    # We must perform one merge per extra chain, so time = n - 1 (or 0 if n == 0/1).
    answer = max(0, n - 1)
    print(answer)

if __name__ == "__main__":
    main()
```