# Chef and Stocks CodeChef Solution

Table of Contents

### We Are Discuss About CODECHEF SOLUTION

# Chef and Stocks CodeChef Solution

## Problem

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.

### Input Format

- The first line of input will contain a single integer $T$, denoting the number of test cases.
- Each test case consists of multiple lines of input.
- The first line of each test case contains $N$ — the number of days.
- The next line denotes $N$ space-separated integers, denoting the profit earned by Chef on the $i_{th}$ day.

### Output Format

For each test case, output on a new line, the **maximum** amount of of profit he would have earned, if he skipped trading for **exactly one** day.

### Constraints

- $1≤T≤1000$
- $1≤N≤1_{5}$
- $−100≤A_{i}≤100$
- The sum of $N$ over all test cases won’t exceed $1_{6}$.

### Sample 1:

4 3 1 -2 3 4 4 1 5 1 4 10 -10 -10 10 5 -5 -4 -3 -2 -1

4 10 10 -10

### Explanation:

**Test case $1$:** To make maximum profit, Chef would have skipped day $2$. The total profit for rest of the days is $1+3=4$.

**Test case $2$:** To make maximum profit, Chef would have skipped day $4$. The total profit for rest of the days is $1+4+5=10$.

**Test case $3$:** To make maximum profit, Chef would have skipped day $3$. The total profit for rest of the days is $10−10+10=10$.

**Test case $4$:** To make maximum profit, Chef would have skipped day $1$. The total profit for rest of the days is $−4−3−2−1=−10$.

6 digit code appear after 69 seconds.

**Wait for Solution**

Yhaa You have done it but next? if YOU Want to Get Others Please Visit Here ScishowEngineer Then **Follow US HERE **and Join Telegram.

If You Want To Learn Something New Then Visit Our Official Channel YOUTUBE