#C684. Final Balance Calculator
Final Balance Calculator
Final Balance Calculator
You are given several test cases where each test case consists of a series of transactions. Your task is to compute the final balance for each test case by summing up the transaction amounts.
For a test case with N transactions having values \(a_1, a_2, \ldots, a_N\), the final balance \(S\) is computed as:
$$ S = \sum_{i=1}^{N} a_i $$
The input begins with an integer \(T\) representing the number of test cases. Each test case starts with an integer \(N\) followed by \(N\) integers denoting the transactions. Output the final balance for each test case on a separate line.
inputFormat
The input is read from standard input (stdin) and has the following format:
- The first line contains an integer \(T\), the number of test cases.
- For each test case:
- The first line contains an integer \(N\), the number of transactions.
- The next \(N\) lines each contain a single integer representing a transaction amount (which may be positive or negative).
outputFormat
Output the final balance for each test case on a separate line to standard output (stdout). The final balance is the sum of all the transaction amounts in that test case.
## sample1
3
-200
300
-100
0