Dessert Wizard

All submissions for this problem are available.
It's finally summer in Chefland! So our chef is looking forward to prepare some of the best "beattheheat" dishes to attract more customers. He summons the Wizard of Dessert to help him with one such dish.
The wizard provides the chef with a sequence of N ingredients where the i^{th} ingredient has a delish value of D[i]. The preparation of the dish takes place in two phases.
Phase 1 : The chef chooses two indices i and j and adds the ingredients i, i+1, ..., j to his dish. He also finds the sum of the delish value in this range i.e D[i] + D[i+1] + ... + D[j].
Phase 2 : The chef chooses two more indices k and l and adds the ingredients k, k+1, ..., l to his dish. He also finds the sum of the delish value in this range i.e D[k] + D[k+1] + ... + D[l].
Note that 1 ≤ i ≤ j < k ≤ l ≤ N.
The total delish value of the dish is determined by the absolute difference between the values obtained in the two phases. Obviously, the chef wants to maximize the total delish value for his dish. So, he hires you to help him.
Input
First line of input contains an integer T denoting the number of test cases. For each test case, the first line contains an integer N denoting the number of ingredients. The next line contains N space separated integers where the i^{th} integer represents the delish value D[i] of the i^{th} ingredient.
Output
Print the maximum delish value of the dish that the chef can get.
Constraints
 1 ≤ T ≤ 50
 2 ≤ N ≤ 10000
 1000000000 (−10^{9}) ≤ D[i] ≤ 1000000000 (10^{9})
Example
Input: 2 5 1 2 3 4 5 4 1 1 1 1 Output: 13 4
Explanation
Example case 1.
Chef can choose i = j = 1, k = 2, l = 5.
The delish value hence obtained is  (2+3+4+5) − (1)  = 13 .
Example case 2.
Chef can choose i = 1, j = 2, k = 3, l = 4.
The delish value hence obtained is  ( ( −1 ) + ( −1 ) ) − ( 1 + 1 )  = 4 .
Author:  viv001 
Tester:  tuananh93 
Editorial  http://discuss.codechef.com/problems/DELISH 
Tags  dynamicprogramming, june13, simple, viv001 
Date Added:  30032013 
Time Limit:  1 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.5, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, CLOJ, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 