#K79707. Final Population Calculation
Final Population Calculation
Final Population Calculation
You are given the initial population of a town and a sequence of daily changes, which can be either positive or negative. Your task is to compute the final population after applying all the changes one by one. The process can be mathematically described by the formula: \( P_{final} = P_{initial} + \sum_{i=1}^{n} c_i \), where \(P_{initial}\) is the initial population and \(c_i\) is the change in population on the \(i^{th}\) day.
inputFormat
The input is provided via standard input (stdin). The first line contains a single integer (P_{initial}) denoting the initial population. The second line contains an integer (n), representing the number of days. The third line contains (n) space-separated integers representing the daily changes.
outputFormat
Output a single integer via standard output (stdout) which is the final population after applying all the daily changes.## sample
1000
4
10 -5 3 -2
1006
</p>