#K65262. Total Savings Calculator

    ID: 32159 Type: Default 1000ms 256MiB

Total Savings Calculator

Total Savings Calculator

You are given a constant daily saving amount \(A\) and the number of days \(D\). For each day, a certain amount is spent. Your task is to calculate the total savings after \(D\) days using the formula:

\(\text{Savings} = \sum_{i=1}^{D}(A - \text{spending}_i)\)

Where:

  • \(A\) is the amount set aside each day.
  • \(D\) is the total number of days.
  • \(\text{spending}_i\) is the spending on the \(i\)-th day.

You are to read the input from standard input (stdin) and write the result to standard output (stdout).

inputFormat

The input consists of two lines:

  • The first line contains two space-separated integers: the daily saving amount \(A\) and the number of days \(D\).
  • The second line contains \(D\) space-separated integers representing the spending for each day.

outputFormat

Output a single integer: the total savings after \(D\) days.

## sample
20 4
10 15 5 10
40