Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
/*
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⡤⠖⠒⠊⠉⠉⠀⣠⠶⠋⠉⡏⠉⠻⣷⡶⢦⣤⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⡴⠚⠉⠀⠀⠀⠀⠀⢀⡤⠞⠁⠀⠀⠀⠀⠀⠀⠈⢷⡀⠀⠉⠻⢦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠞⠁⠀⠀⠀⠀⠀⠀⣀⡴⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢷⡀⠀⠀⠀⠙⢦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡰⠋⠀⠀⠀⠀⠀⠀⠀⣠⠞⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣷⠀⠀⠀⠀⠀⢹⣦⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⠁⠀⠀⠀⠀⠀⠀⠀⣼⣧⣶⣤⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⠀⠀⠀⠀⠀⠀⢻⣷⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⠀⠀⠀⠀⠀⠀⢠⣾⡟⠉⠀⠙⣿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⠀⠀⠀⠀⠀⠀⠨⣿⡇⠀⠀⠀⣠⠚⢦⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⠀⠀⠀⠀⠀⣰⡿⠁⡇⠀⠀⠀⠈⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⡆⠀⠀⠀⠀⠀⠀⣿⡇⢀⡴⠊⠁⠀⠈⣆⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⠀⠀⠀⠀⠘⢿⣧⣄⣁⣀⣀⣀⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⡇⠀⠀⠀⠀⠀⠀⣿⡗⠋⠀⠀⠀⠀⠀⠘⣆⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⡀⠀⠀⠀⠀⠀⠈⠙⠛⠛⠉⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣇⠀⠀⠀⠀⠀⣴⣿⠀⠀⠀⠀⠀⠀⠀⠀⠘⣆⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣀⣤⣶⡿⠻⣦⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡀⣀⣠⣀⣏⢀⣠⣤⠴⠖⠛⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⡆⠀⠀
⠀⠀⠀⣠⣴⡿⢿⠟⠉⠀⠀⠀⠉⠛⠲⠦⢤⣤⣄⣀⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣠⡾⣿⣿⠝⠏⢻⡉⠉⠀⠀⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⡄⠀
⠀⠀⢸⣿⣿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠉⠉⠉⠉⠉⠉⠉⠉⢉⣿⠿⠋⡇⠀⠀⠀⠀⠈⢷⠀⠀⠀⠀⠀⠈⣇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠹⡄
⠀⠀⠀⠙⢿⢾⣭⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣴⡶⠟⣿⡿⠀⠀⡇⠀⠀⠀⠀⠀⠈⣇⠀⠀⠀⠀⠀⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡀⡿
⠀⠀⠀⠀⠸⡀⠀⠉⠛⠓⢶⣦⣤⣤⡤⠤⠤⠤⢴⣷⡶⠚⠛⠋⠁⠀⠙⠛⠛⣡⡤⠤⡇⠀⠀⠀⠀⠀⠀⢸⡄⠀⠀⠀⢀⣿⡀⠀⠀⠀⠀⠀⠀⠀⠀⣘⡿⠁
⠀⠀⠀⠀⠀⢣⡀⠀⠀⠀⢸⡇⠀⢹⡇⠀⠀⠀⠘⠛⠁⠀⠀⠀⠀⠀⠀⠀⣾⠁⠀⠀⣿⠀⠀⠀⠀⠀⠀⠀⣧⠀⠀⠀⣸⣿⡇⠀⠀⠀⠀⠀⠀⠀⢀⠟⠀⠀
⠀⠀⠀⠀⠀⠀⢳⠀⠀⠀⠘⢷⣀⣼⠃⠀⠀⣠⡤⢦⣀⠀⠀⠀⠀⠀⠀⠀⢹⣖⣦⣤⣿⡇⠀⠀⠀⠀⠀⠀⢸⠀⠠⣰⣿⣿⡇⠀⠀⠀⠀⠀⢀⣤⠟⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⢳⡀⠀⠀⠈⢯⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠉⠛⠉⣧⠀⠀⠀⠀⠀⠀⢸⣷⣴⣿⣿⣿⡇⠀⠀⠀⠀⢠⣻⠋⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⢳⡀⠀⠀⠀⠙⢦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⡀⠀⠀⠀⠀⠀⢸⢸⠿⣿⣿⣿⡇⠀⠀⠀⠰⡿⠃⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⣾⣿⣄⠀⠀⠀⡾⠙⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣇⠀⠀⠀⠀⠀⢸⢸⠀⠀⠙⠿⠇⠀⠀⢀⡟⠃⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⠟⠳⡄⢰⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠀⠀⠀⠀⠀⢡⣿⠀⠀⠀⠀⠀⠀⣄⡞⠁⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⠀⢉⡞⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣯⠀⠀⠀⠀⠀⣰⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡼⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⡷⣄⠀⠀⠸⢿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⠞⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⡇⠈⣳⣤⣄⣈⣧⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⣠⣴⡄⠀⠀⢀⡴⠚⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢳⣾⣿⣿⠿⠛⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀
⢰⠿⠛⠹⡆⡴⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⠿⠋⠁⢀⣠⣤⣤⣤⣄⡀⠀⠀⠀⠀⠀
⢸⠀⠀⡀⠹⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣴⣾⡟⠿⣆⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⢀⡴⠟⠉⠁⠀⠀⢰⡾⠛⠷⣦⡀⠀⠀
⢸⡄⠀⡇⠀⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢿⠀⠀⠀⠘⣇⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⡆⠀⠀⠀⠀⠘⢷⡀⠀⠈⢿⣄⠀
⠀⡇⠀⣇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⢸⡀⠀⠀⠀⠀⠀⠀⣴⣿⣿⣿⠃⠀⠀⠀⠀⠀⠈⠳⢤⣀⣸⣿⡀
⠀⢳⡀⢸⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⡇⠀⠀⠀⠀⣧⠀⠀⠀⠀⢠⣴⣿⣿⣿⡟⠀⠀⠀⠀⠀⠀⢀⡀⠈⠛⣚⣿⡇
⠀⠈⢷⠀⠙⣦⣤⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢿⠀⠀⠀⠀⠸⡄⢀⣠⠞⠉⣰⠛⣿⣿⣧⡀⠀⠀⣠⣾⣟⠿⣧⣀⣤⣿⢿⠁
⠀⠀⠈⠳⠴⢷⣄⠈⠳⣄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⡆⠀⠀⠀⠀⡇⠁⠀⠀⣰⠏⠀⠹⡌⢩⠛⠻⠿⢿⣿⣿⣶⣽⠛⠉⢠⠟⠀
⠀⠀⠀⠀⠀⠀⠙⠳⢤⣀⡉⠁⠀⠀⠀⠀⠀⠀⢀⣀⣀⣀⣀⣀⣀⣀⣀⡀⠀⠀⠹⣄⡀⠀⣸⠁⣀⡤⠞⠁⠀⠀⠀⠙⠦⣳⣄⡀⠀⠙⠛⠛⠁⣀⡼⠁⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⢀⡀⡉⠙⠛⠛⠛⠛⠛⠉⠉⠀⠀⠀⠀⠀⠀⠀⠀⠉⠙⠛⠓⠚⠛⠛⠛⠉⠁⠀⠀⠠⠤⠀⠐⠲⢤⡈⣙⡛⠛⠒⠒⠒⠛⠁⠀⠀⠀⠀
*/

#include <bits/stdc++.h>
#define int long long 
#define INF INT64_MAX
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define vi vector<int>
#define vvi vector<vector<int> >

using namespace std;

template<typename T>
ostream& operator<< (ostream& out, array<T, 2> arr) {
    return out << arr[0] << ' ' << arr[1] << ' ';
}

template<typename T>
void print(T el) {
    cout << el << ' ';
}

template<typename T>
void print(vector<T> v) {
    for(auto x : v) print(x);
    cout << '\n';
}

template<typename T>
void print(vector<vector<T> > v) {
    for(auto x : v) {
        for(auto y : x) print(y);
        cout << '\n';
    }
}

template<typename T1, typename T2>
void print(map<T1, T2> m) {
    for (auto [x, y] : m) {
        cout << "{" << x << " : " << y << "} ";
    } cout << '\n';
}

template<typename T>
void print(set<T> s) {
    for (auto x : s) print(x);
    cout << '\n';
}


void solve() {
    int n;
    cin >> n;
    vi v(n), v2(n);
    for (int& x : v) cin >> x;
    v2 = v;
    if (n == 1) {
        cout << v[0] << '\n';
        return;
    }
    int s = accumulate(all(v), 0ll);
    for (int i = 0; i < n-2; i++) {
        for (int j = 0; j < v.size()-1; j++) {
            v[j] = v[j+1]-v[j];
        }
        v.pop_back();
        // print(v);
    }
    for (int i = 0; i < n-2; i++) {
        for (int j = 0; j < v2.size()-1; j++) {
            v2[j] = v2[j]-v2[j+1];
        }
        v2.pop_back();
        // print(v2);
    }
    cout << max({s, abs(v[0]-v[1]), abs(v2[0]-v2[1])}) << '\n';
    // for (int i = 0; i < n; i++) {
    //     int s1 = 0, s2 = 0, s = v[0];
    //     if (v.size() == 1) {
    //         cout << s << '\n';
    //         return;
    //     }
    //     for (int j = 0; j < v.size()-1; j++) {
    //         s1+=v[j+1]-v[j];
    //         s2+=v[j]-v[j+1];
    //         s+=v[j+1];
    //         cout << v[j+1]-v[j] << ' ' << s1 << ' ' << s2 << ' ' << s << '\n';
    //     }
    //     print(v);
    //     if (max({s1, s2, s}) == s) {
    //         cout << s << '\n';
    //         return;
    //     } else if (s1 > s2) {
            // for (int j = 0; j < v.size()-1; j++) {
            //     v[j] = v[j+1]-v[j];
            // }
            // v.pop_back();
    //     } else {
            // for (int j = 0; j < v.size()-1; j++) {
            //     v[j] = v[j]-v[j+1];
            // }
            // v.pop_back();
    //     }
    // }
}

int32_t main () {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int t = 1;
    cin >> t;
    while(t--) {
        solve();
    }
}

Submission (verdict: Accepted):
/*
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⡤⠖⠒⠊⠉⠉⠀⣠⠶⠋⠉⡏⠉⠻⣷⡶⢦⣤⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⡴⠚⠉⠀⠀⠀⠀⠀⢀⡤⠞⠁⠀⠀⠀⠀⠀⠀⠈⢷⡀⠀⠉⠻⢦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠞⠁⠀⠀⠀⠀⠀⠀⣀⡴⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢷⡀⠀⠀⠀⠙⢦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡰⠋⠀⠀⠀⠀⠀⠀⠀⣠⠞⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣷⠀⠀⠀⠀⠀⢹⣦⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⠁⠀⠀⠀⠀⠀⠀⠀⣼⣧⣶⣤⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⠀⠀⠀⠀⠀⠀⢻⣷⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⠀⠀⠀⠀⠀⠀⢠⣾⡟⠉⠀⠙⣿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⠀⠀⠀⠀⠀⠀⠨⣿⡇⠀⠀⠀⣠⠚⢦⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⠀⠀⠀⠀⠀⣰⡿⠁⡇⠀⠀⠀⠈⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⡆⠀⠀⠀⠀⠀⠀⣿⡇⢀⡴⠊⠁⠀⠈⣆⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⠀⠀⠀⠀⠘⢿⣧⣄⣁⣀⣀⣀⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⡇⠀⠀⠀⠀⠀⠀⣿⡗⠋⠀⠀⠀⠀⠀⠘⣆⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⡀⠀⠀⠀⠀⠀⠈⠙⠛⠛⠉⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣇⠀⠀⠀⠀⠀⣴⣿⠀⠀⠀⠀⠀⠀⠀⠀⠘⣆⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣀⣤⣶⡿⠻⣦⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡀⣀⣠⣀⣏⢀⣠⣤⠴⠖⠛⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⡆⠀⠀
⠀⠀⠀⣠⣴⡿⢿⠟⠉⠀⠀⠀⠉⠛⠲⠦⢤⣤⣄⣀⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣠⡾⣿⣿⠝⠏⢻⡉⠉⠀⠀⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⡄⠀
⠀⠀⢸⣿⣿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠉⠉⠉⠉⠉⠉⠉⠉⢉⣿⠿⠋⡇⠀⠀⠀⠀⠈⢷⠀⠀⠀⠀⠀⠈⣇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠹⡄
⠀⠀⠀⠙⢿⢾⣭⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣴⡶⠟⣿⡿⠀⠀⡇⠀⠀⠀⠀⠀⠈⣇⠀⠀⠀⠀⠀⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡀⡿
⠀⠀⠀⠀⠸⡀⠀⠉⠛⠓⢶⣦⣤⣤⡤⠤⠤⠤⢴⣷⡶⠚⠛⠋⠁⠀⠙⠛⠛⣡⡤⠤⡇⠀⠀⠀⠀⠀⠀⢸⡄⠀⠀⠀⢀⣿⡀⠀⠀⠀⠀⠀⠀⠀⠀⣘⡿⠁
⠀⠀⠀⠀⠀⢣⡀⠀⠀⠀⢸⡇⠀⢹⡇⠀⠀⠀⠘⠛⠁⠀⠀⠀⠀⠀⠀⠀⣾⠁⠀⠀⣿⠀⠀⠀⠀⠀⠀⠀⣧⠀⠀⠀⣸⣿⡇⠀⠀⠀⠀⠀⠀⠀⢀⠟⠀⠀
⠀⠀⠀⠀⠀⠀⢳⠀⠀⠀⠘⢷⣀⣼⠃⠀⠀⣠⡤⢦⣀⠀⠀⠀⠀⠀⠀⠀⢹⣖⣦⣤⣿⡇⠀⠀⠀⠀⠀⠀⢸⠀⠠⣰⣿⣿⡇⠀⠀⠀⠀⠀⢀⣤⠟⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⢳⡀⠀⠀⠈⢯⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠉⠛⠉⣧⠀⠀⠀⠀⠀⠀⢸⣷⣴⣿⣿⣿⡇⠀⠀⠀⠀⢠⣻⠋⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⢳⡀⠀⠀⠀⠙⢦⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⡀⠀⠀⠀⠀⠀⢸⢸⠿⣿⣿⣿⡇⠀⠀⠀⠰⡿⠃⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⣾⣿⣄⠀⠀⠀⡾⠙⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣇⠀⠀⠀⠀⠀⢸⢸⠀⠀⠙⠿⠇⠀⠀⢀⡟⠃⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⠟⠳⡄⢰⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠀⠀⠀⠀⠀⢡⣿⠀⠀⠀⠀⠀⠀⣄⡞⠁⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⠀⢉⡞⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣯⠀⠀⠀⠀⠀⣰⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡼⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⡷⣄⠀⠀⠸⢿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⠞⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⡇⠈⣳⣤⣄⣈⣧⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⣠⣴⡄⠀⠀⢀⡴⠚⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢳⣾⣿⣿⠿⠛⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀
⢰⠿⠛⠹⡆⡴⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⠿⠋⠁⢀⣠⣤⣤⣤⣄⡀⠀⠀⠀⠀⠀
⢸⠀⠀⡀⠹⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣴⣾⡟⠿⣆⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⢀⡴⠟⠉⠁⠀⠀⢰⡾⠛⠷⣦⡀⠀⠀
⢸⡄⠀⡇⠀⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢿⠀⠀⠀⠘⣇⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⡆⠀⠀⠀⠀⠘⢷⡀⠀⠈⢿⣄⠀
⠀⡇⠀⣇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⢸⡀⠀⠀⠀⠀⠀⠀⣴⣿⣿⣿⠃⠀⠀⠀⠀⠀⠈⠳⢤⣀⣸⣿⡀
⠀⢳⡀⢸⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⡇⠀⠀⠀⠀⣧⠀⠀⠀⠀⢠⣴⣿⣿⣿⡟⠀⠀⠀⠀⠀⠀⢀⡀⠈⠛⣚⣿⡇
⠀⠈⢷⠀⠙⣦⣤⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢿⠀⠀⠀⠀⠸⡄⢀⣠⠞⠉⣰⠛⣿⣿⣧⡀⠀⠀⣠⣾⣟⠿⣧⣀⣤⣿⢿⠁
⠀⠀⠈⠳⠴⢷⣄⠈⠳⣄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⡆⠀⠀⠀⠀⡇⠁⠀⠀⣰⠏⠀⠹⡌⢩⠛⠻⠿⢿⣿⣿⣶⣽⠛⠉⢠⠟⠀
⠀⠀⠀⠀⠀⠀⠙⠳⢤⣀⡉⠁⠀⠀⠀⠀⠀⠀⢀⣀⣀⣀⣀⣀⣀⣀⣀⡀⠀⠀⠹⣄⡀⠀⣸⠁⣀⡤⠞⠁⠀⠀⠀⠙⠦⣳⣄⡀⠀⠙⠛⠛⠁⣀⡼⠁⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⢀⡀⡉⠙⠛⠛⠛⠛⠛⠉⠉⠀⠀⠀⠀⠀⠀⠀⠀⠉⠙⠛⠓⠚⠛⠛⠛⠉⠁⠀⠀⠠⠤⠀⠐⠲⢤⡈⣙⡛⠛⠒⠒⠒⠛⠁⠀⠀⠀⠀
*/

#include <bits/stdc++.h>
#define int long long 
#define INF INT64_MAX
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define vi vector<int>
#define vvi vector<vector<int> >

using namespace std;

template<typename T>
ostream& operator<< (ostream& out, array<T, 2> arr) {
    return out << arr[0] << ' ' << arr[1] << ' ';
}

template<typename T>
void print(T el) {
    cout << el << ' ';
}

template<typename T>
void print(vector<T> v) {
    for(auto x : v) print(x);
    cout << '\n';
}

template<typename T>
void print(vector<vector<T> > v) {
    for(auto x : v) {
        for(auto y : x) print(y);
        cout << '\n';
    }
}

template<typename T1, typename T2>
void print(map<T1, T2> m) {
    for (auto [x, y] : m) {
        cout << "{" << x << " : " << y << "} ";
    } cout << '\n';
}

template<typename T>
void print(set<T> s) {
    for (auto x : s) print(x);
    cout << '\n';
}


void solve() {
    int n;
    cin >> n;
    vi v(n), v2(n);
    for (int& x : v) cin >> x;
    // v2 = v;
    if (n == 1) {
        cout << v[0] << '\n';
        return;
    }
    int s = accumulate(all(v), 0ll);
    // for (int i = 0; i < n-2; i++) {
    //     for (int j = 0; j < v.size()-1; j++) {
    //         v[j] = v[j+1]-v[j];
    //     }
    //     v.pop_back();
    //     // print(v);
    // }
    // for (int i = 0; i < n-2; i++) {
    //     for (int j = 0; j < v2.size()-1; j++) {
    //         v2[j] = v2[j]-v2[j+1];
    //     }
    //     v2.pop_back();
    //     // print(v2);
    // }
    // cout << max({s, abs(v[0]-v[1]), abs(v2[0]-v2[1])}) << '\n';
    for (int i = 0; i < n-1; i++) {
        int s1 = 0, s2 = 0, ss = v[0];
        for (int j = 0; j < v.size()-1; j++) {
            s1+=v[j+1]-v[j];
            s2+=v[j]-v[j+1];
            ss+=v[j+1];
            // cout << v[j+1]-v[j] << ' ' << s1 << ' ' << s2 << ' ' << s << '\n';
        }
        s = max(ss, s);
        // print(v);
        if (s1 > s2) {
            for (int j = 0; j < v.size()-1; j++) {
                v[j] = v[j+1]-v[j];
            }
            v.pop_back();
        } else {
            for (int j = 0; j < v.size()-1; j++) {
                v[j] = v[j]-v[j+1];
            }
            v.pop_back();
        }
    }
    cout << max(s, v[0]) << '\n';
}

int32_t main () {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int t = 1;
    cin >> t;
    while(t--) {
        solve();
    }
}