Problem: 2062C - Cirno and Operations
Language: c++17 

Solution 1 (runtime: 62 ms):
#include <bits/stdc++.h>
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int MOD = 1e9 + 7;
const int INF = 1e9;
const int N_max = 2e5 + 1;

int eea(int a, int b, int &x, int &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    int x1, y1;
    int d = eea(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}

// for prime m
ll inv_prime(ll a, ll m) {
  return a <= 1 ? a : m - (ll) (m/a) * inv_prime(m % a, m) % m;
}

ll bipower(ll a, ll n) {
    ll res = 1;
    while (n) {
        if (n & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        n >>= 1;
    } 
    return res;
}

class min_queue {
    deque<int> elems;
    deque<int> mins;
    deque<int> idxs;
    int cnt;
public:
    min_queue() {cnt = 0;}
    ~min_queue() {}

    void push(int elem) {
        elems.push_back(elem);
        while (!mins.empty() && mins.back() >= elem) {
            mins.pop_back();
            idxs.pop_back();
        }

        mins.push_back(elem);
        idxs.push_back(cnt++);        
    }

    int pop() {
        if (!elems.empty()) {
            if (!idxs.empty() && idxs.front() == cnt - elems.size()) {
                mins.pop_front();
                idxs.pop_front();
            }

            int el = elems.front();
            elems.pop_front();
            return el;
        }
        return -1;
    }

    int get_min() {
        if (!mins.empty())
            return mins.front();
        return -1;
    }

    size_t size() {
        return elems.size();
    }

    bool empty() {
        return size() == 0;
    }
};

void dfs(vector<vi>& g, vi& subtrees, vi& parents, vector<bool>& vis, int current, int depth, ll& total) {
    vis[current] = true;
    total += depth;
    subtrees[current] = 1;
    for (auto &e : g[current]) {
        if (!vis[e]) {
            parents[e] = current;
            dfs(g, subtrees, parents, vis, e, depth + 1, total);
            subtrees[current] += subtrees[e];
        }
    }
}

void solve() {
    int n;
    cin >> n;
    vll a(n);
    for (auto &e : a)
        cin >> e;
    if (n == 1) {
        cout << a[0] << "\n";
        return;
    }

    ll res = 0;
    for (int i = 0; i < n; i++)
        res += a[i];

    ll tmp = 0;
    while (a.size() > 1) {
        tmp = 0;

        for (int i = 0; i < a.size() - 1; i++)
            a[i] = a[i + 1] - a[i];

        a.pop_back();

        for (int i = 0; i < a.size(); i++)
            tmp += a[i];
        
        res = max(res, abs(tmp));
    }

    cout << res << "\n";
}
 
 
int main(){
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    int T = 1;
    cin >> T;
    while(T--)
        solve();
    return 0;
}

Solution 2 (runtime: 62 ms):
#include <bits/stdc++.h>
using namespace std;
#define fastread() (ios_base::sync_with_stdio(false),cin.tie(NULL))
#define ll long long
#define sp " "
#define nl "\n"
#define sum_vector(v) accumulate(v.begin(),v.end(),0LL)

#define ON(n,k)         ((n)| (1<<(k)))
#define OFF(n,k)        ((n)& (~(1<<(k))))
#define GetBit(n,k)     (((n)>> (k)) & 1 )
#define flibBit(n,k)    ((n)^(1<<(k)))
#define IsPowerOfTwo(n) (((n)&(n-1))==0)
#define IsOdd(n)        ((n) & 1 )


#define ONll(n,k)         ((n)| (1LL<<(k)))
#define OFFll(n,k)        ((n)& (~(1LL<<(k))))
#define GetBitll(n,k)     (((n)>> (k)) & 1LL )
#define flibBitll(n,k)    ((n)^(1LL<<(k)))
#define IsPowerOfTwoll(n) (((n)&(n-1))==0)
#define IsOddll(n)        ((n) & 1LL )


ll fast_power(ll base , ll pwr)
{
    if(pwr==0) return 1;
    ll p= fast_power(base, pwr/2);
    
    if(pwr%2 == 0) return p*p;

    return p*p*base;
}
ll sumtoN(ll n)
{
    return n*(n+1)/2;
}

ll lcm(ll a, ll b) {
    return (a / __gcd(a, b)) * b;
}




const int N=1e5+5;
int n,m,u,v, oo= 0x3f3f3f3f;
vector<int> adj[N];    
int dis[N]; 
const int NOT_IN_GROUP =0, G1=1, G2=2;
int group[N];
ll ng1=0,ng2=0;


bool Is_bipartite(int src)
{
    group[src]=G1;
    ng1++;
    queue<int>q;
    q.push(src);
    
    while(!q.empty())
    {
        int tp=q.front();
        q.pop();
        for(int ch: adj[tp])
        {
            if(group[ch]== NOT_IN_GROUP)
            {
                group[ch] = (group[tp]==G1 ? G2:G1);
                if(group[ch]==G1) ng1++;
                else ng2++;
                q.push(ch);
            }
            else if(group[ch]==group[tp])
            {
                return false;
            }
        }
    }
    
    return true;
}



void solution()
{
    int n; cin>>n;
    vector<ll>v(n+1,0);
    int neg=false;
    for(int i=1; i<=n; i++)
    {
        cin>>v[i];
        if(v[i]<0)
        {
            neg=true;
        }
    }
    ll first_sum= sum_vector(v);
    ll mx_sum=first_sum;
    if(n==1)
    {
        cout<<first_sum<<nl;
        return;
    }
    while(n>1)
    {
        first_sum=abs(v[n]-v[1]);
        mx_sum=max(mx_sum,first_sum);
        
        for(int i=1; i<n; i++)
        {
            v[i]=v[i+1]-v[i];
        }
        v.pop_back();
        n--;

    }
    
    cout<<mx_sum<<nl;

}


int main() {
    fastread();
 
    int t=1;
    cin>>t;
    while(t--) {
        solution();
    }
    
    return 0;
}