Loading...
Candy Count
Time: 2 s
Memory: 125 MB
Amir Hozaifa is a respected competitive programming trainer, and his junior admire him greatly. One day, Amir Hozaifa brought some candies to share with his junior after a successful training session. However, throughout the day, his junior either gave him candies to show their gratitude or took some candies as rewards for solving challenging problems. Since Amir Hozaifa is their trainer, none of the junior would ever take more candies than Amir Hozaifa currently has.

Here’s how the day unfolded:
Amir Hozaifa started the day with \(N\) candies. Rakib gave him \(P\) candies. Sagor took \(Q\) candies as a reward. Shawqi gave him \(R\) candies. Rifat took \(S\) candies as a reward. Osama gave him \(T\) candies. Meheraj took \(U\) candies as a reward. Tafsir gave him \(V\) candies. Finally, Labib took \(W\) candies as a reward.

At the end of all these interactions, Amir Hozaifa wants to know how many candies he has. Your task is to calculate the total number of candies Amir has after all these events.
Input
The first line contains a single integer \(N\) — the number of candies Amir Hozaifa starts with.
The second line contains eight integers  \(P, Q, R, S, T, U, V, W\) — the number of candies given or taken by the his junior in sequence.
Constraint
\(0 \leq N \leq 10^9 \)
\(0 \leq P, Q, R, S, T, U, V, W \leq 10^9\)
Output
Print a single integer — the number of candies Amir Hozaifa has at the end.
Examples
Input
Output
100
20 30 10 50 10 30 60 20
70
Input
Output
50
10 10 10 10 10 10 10 10
50
Input
Output
50
10 10 10 10 10 10 10 60
0
Notes
Explanation for testcase #1
Amir Hozaifa starts the day with \(100\) candies. Rakib gives him \(20\) candies, so now he has \(120\) candies. Sagor takes \(30\) candies, leaving him with \(90\) candies. Shawqi gives him \(10\) candies, making it \(100\) candies. Rifat takes \(50\) candies, so now he has \(50\) candies. Osama gives him \(10\) candies, making it \(60\) candies. Meheraj takes \(30\) candies, leaving him with \(30\) candies. Tafsir gives him \(60\) candies, so now he has \(90\) candies. Finally, Labib takes \(20\) candies, and Amir Hozaifa ends the day with \(70\) candies.
Problem Info
Problem ID 375
Time Limit 2000 ms
Memory Limit 128000 KB
Moderators lauhemahfus , refred1 , amirhozaifa , tafsiruzzaman , meheraj_hossain_ , osama_bq , sagorahmedmunna , Dr_KeK , Rakib , fahimcp495
Statistics
Submit
You need to Login or Registration for submit your solution