#C4946. Minimum Total Energy for Oven Baking
Minimum Total Energy for Oven Baking
Minimum Total Energy for Oven Baking
You are given n cakes to bake in an oven. Each cake requires a specific temperature to bake. The energy required to bake a cake is equal to its required temperature.
Your task is to determine the minimum total energy needed to bake all the cakes sequentially (i.e. one after the other). Mathematically, if the required temperatures are given by \(T_1, T_2, \dots, T_n\), the answer is:
\(E = \sum_{i=1}^{n} T_i\)
If there are no cakes (i.e. \(n = 0\)), the total energy is 0.
inputFormat
The first line contains an integer n
representing the number of cakes. If n > 0
, the second line contains n
space-separated integers representing the required temperatures for each cake.
Note: In case n = 0
, there will be no second line.
outputFormat
Output a single integer representing the minimum total energy required to bake all the cakes.
## sample4
2 3 5 7
17