eolymp
bolt
Try our new interface for solving problems
Problems

Chef and Stocks

Chef and Stocks

Chef has started learning about the stock market and has already selected a favourite stock. He traded the stock for $n$ consecutive days. Let $a_i$ denotes the profit earned by Chef on the $i$-th day. Note that $a_i < 0$ indicates that Chef had a loss on the $i$-th day. Chef wants to find the maximum amount of of profit he would have earned, if he skipped trading for exactly one day. \InputFile The first line contains the number of test cases $t~(1 \le t \le 1000)$. The first line of each test case contains $n~(1 \le n \le 10^5)$ --- the number of days. The next line denotes $n$ integers $a_i~(-100 \le a_i \le 100)$, denoting the profit earned by Chef on the $i$-th day. \OutputFile For each test case, print on a new line the maximum amount of profit he would have earned, if he skipped trading for exactly one day.
Time limit 1 second
Memory limit 128 MiB
Input example #1
4
3
1 -2 3
4
4 1 5 1
4
10 -10 -10 10
5
-5 -4 -3 -2 -1
Output example #1
4
10
10
-10