#K38977. Minimum Campus Construction Cost

    ID: 26318 Type: Default 1000ms 256MiB

Minimum Campus Construction Cost

Minimum Campus Construction Cost

You are given an integer \( M \) representing the number of buildings and a list of \( M \) integers \( C_1, C_2, \ldots, C_M \) representing the cost to connect each building. The campus must be constructed such that all buildings are connected in a tree structure. In a tree with \( M \) nodes, there are exactly \( M - 1 \) connections.

For this problem, the minimum cost to construct the campus is defined as the sum of all the connection costs:

\( \text{cost} = \sum_{i=1}^{M} C_i \)

Your task is to compute and output this sum.

inputFormat

The input is given via standard input (stdin) in the following format:

  • The first line contains an integer \( M \) representing the number of buildings.
  • The second line contains \( M \) space-separated integers \( C_1, C_2, \ldots, C_M \), where each \( C_i \) represents the cost of connecting the \( i\)-th building.

outputFormat

Output a single integer on standard output (stdout), which is the minimum cost to construct the campus.

## sample
4
1 2 3 4
10

</p>