#K8981. Total Cable Length in a Cyclic Computer Network

    ID: 37613 Type: Default 1000ms 256MiB

Total Cable Length in a Cyclic Computer Network

Total Cable Length in a Cyclic Computer Network

You are given a cyclic network of computer stations. In the network, there are n computer stations arranged in a circle. The distance between each pair of consecutive stations is provided in an array. Your task is to calculate the total cable length required to connect all stations in the network.

Formally, if the distances between consecutive stations are represented as \(d_1, d_2, \ldots, d_n\), you need to compute the sum \[ \text{Total Cable Length} = \sum_{i=1}^{n} d_i \]

Constraints:

  • 3 \(\leq n \leq\) 100
  • 1 \(\leq d_i \leq\) 1000

inputFormat

The input is given via stdin and consists of two lines:

  1. The first line contains an integer n, representing the number of computer stations.
  2. The second line contains n space-separated integers, where each integer \(d_i\) represents the distance between the \(i^{th}\) and the \((i+1)^{th}\) station in a circular order.

outputFormat

The output is a single integer printed to stdout which is the total cable length required to connect all the stations.

## sample
5
3 2 5 4 1
15