SP8407 CANDYSTN - Candies and Milestones
Description
Little Pratya loves collecting candies and she also likes playing games :).
Today Pratya is travelling in bus and she has a bag full of **N** candies. She looks outside the window and notices milestones with numbers written on them. She decides to play a game. She wants to select some initial _non-zero_ number of candies from the bag and call it her collection of candies. When she sees a milestone on the way, she will add or remove some candies from her collection as following.
Let the previous milestone number be **a1** and the current milestone number be **a2**. 
**a2 > a1 :** Pratya adds ( a2 - a1 ) candies to her collection (thus, her bag of candies loses them). If the bag doesn't contain at least ( a2 - a1 ) candies, she starts crying.
**a2 < a1 :** Pratya removes ( a1 - a2 ) candies from her collection (thus, her bag of candies gains them). If her collection doesn't contain more than ( a1 - a2 ) candies, she starts crying.
**a1 = a2 :** Pratya is bored to see the same number again and so she eats one of the candies from her collection.
Moreover, Pratya always wants her candy collection to have at least one candy, otherwise she starts crying. Given the numbers written on all the milestones in order, find the minimum number of candies Pratya should select in the beginning so that she doesn't have to cry at all. If it is not possible , print -1. Note that no change to the collection happens when she sees the first milestone.
Input Format
The first line contain the number of test cases **T**. Each test case has two lines. The first line specifies **N** and **M**. **N** is the number of candies in the bag and **M** is the total number of milestones. Second line contains **M** integers, the numbers written on the milestones, in the order Pratya sees them.
^ is used for power.
T
Output Format
For each test case output the minimum number of candies that should be selected from the bag or -1 if its not possible