#K2791. Minimum Lights Required for Decorating Trees
Minimum Lights Required for Decorating Trees
Minimum Lights Required for Decorating Trees
You are given n trees with corresponding heights. Each tree requires a number of lights equal to its height. Your task is to determine the minimum number of lights needed to decorate all trees.
Formally, given a sequence of tree heights \( h_1, h_2, \dots, h_n \), you need to compute the sum:
\( \sum_{i=1}^{n} h_i \)
Input is provided from standard input and output should be printed to standard output.
inputFormat
The first line contains an integer n, representing the number of trees.
The second line contains n space-separated integers, where the i-th integer represents the height of the i-th tree.
Note: Input is read from stdin
.
outputFormat
Output a single integer representing the minimum number of lights required, which is the sum of the heights of all trees.
Note: Output should be printed to stdout
.
3
4 2 3
9