#C8865. Minimum Wall Width

    ID: 52894 Type: Default 1000ms 256MiB

Minimum Wall Width

Minimum Wall Width

You are given the number of paintings created by several artists. Each painting occupies 1 unit of width on the wall. In addition, if paintings of different artists are displayed consecutively, a gap of 2 units is required between each pair of artists. Given a list in which each element represents the number of paintings for a distinct artist, your task is to calculate the minimum width of the wall required to display all the paintings together.

More formally, if there are \(n\) artists and the number of paintings for each artist is \(a_1, a_2, \ldots, a_n\), then the answer is:

[ \text{result} = \left(\sum_{i=1}^{n} a_i\right) + 2 \times (n - 1). ]

Input is provided via standard input (stdin) and the result should be output to standard output (stdout).

inputFormat

The first line contains an integer \(n\) representing the number of artists. The second line contains \(n\) space-separated integers, where each integer represents the number of paintings by the corresponding artist.

outputFormat

Output a single integer representing the minimum width of the wall required to display all the paintings with the required gaps.

## sample
3
3 2 1
10