P15770 [CodeChef] WC04
普及
题目描述

Blob is a computer science student. He recently got an internship from Chef's enterprise. Along with the programming he has various other skills too like graphic designing, digital marketing and social media management. Looking at his skills Chef has provided him different tasks A[1…N] which have their own scores. Blog wants to maximize the value of the expression A[d]-A[c]+A[b]-A[a] such that d>c>b>a.

Can you help him in this?

-----Input:-----
- The first line contain the integer N
- The second line contains N space separated integers representing A[1], A[2] … A[N]

-----Output:-----
The maximum score that is possible

-----Constraints-----
- $4 \leq N \leq 10^4$
- $0 \leq A[i] \leq 10^5$

-----Sample Input:-----
6

3 9 10 1 30 40

-----Sample Output:-----
46

输入格式

见题面

输出格式

见题面

样例输入
['6', '3 9 10 1 30 40']
样例输出
['46']