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

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#include <cmath>
#include <string>
using namespace std;

#define ll long long
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);

ll MOD = 1e9 + 7;

ll fastPower(ll x, ll n) {
    ll ans = 1;
    while(n > 0) {
        if(n % 2 == 1) ans = ans * x;
        x = x * x;
        n /= 2;
    }
    return ans;
}

set<ll> divisors(ll n) 
{ 
    set<ll> res;
    for (int i=1; i * i<=n; i++) { 
        if (n%i == 0) { 
            res.insert(i);
            res.insert(n / i);
        } 
    } 
    return res;
} 

vector<ll> primeFact(ll n) {
    vector<ll> res;
    for(ll i=2; i * i <= n; ++i) {
        while(n % i == 0) {
            res.push_back(i);
            n /= i;
        }
    }
    if(n != 1) res.push_back(n);
    return res;
}

ll gcd(ll a,ll b) {
  ll R;
  while ((a % b) > 0)  {
    R = a % b;
    a = b;
    b = R;
  }
  return b;
}

string decimalToBinary(ll n) {
    string binary = "";
    while (n > 0) {
        binary = to_string(n % 2) + binary;
        n /= 2;
    }
    return binary;
}

void solve(vector<ll> v) {
    ll n = v.size();
    ll ans = 0;
    ll cur = 0;
    for(ll i=0; i<n; ++i) {
        ans += v[i];
    }
    ans = abs(ans);
    while(n > 1) {
        vector<ll> v2;
        cur = 0;
        for(ll i=0; i<n - 1; ++i) {
            ll num1 = v[i + 1];
            ll num2 = v[i];
            ll dif = num1 - num2;
            v2.push_back(dif);
            cur += abs(dif);
        }
        v.clear();
        for(ll i=0; i<n - 1; ++i) {
            v.push_back(v2[i]);
        }
        v2.clear();
        n--;
        ans = max(ans, cur);
    }
    cout << ans << "\n";
}

int main() {
    fastio;
    ll t;
    cin >> t;
    while(t--) {
        ll n;
        cin >> n;
        vector<ll> v;
        for(ll i=0; i<n; ++i) {
            ll a;
            cin >> a;
            v.push_back(a);
        }
        solve(v);
    }
    return 0;
}


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#include <cmath>
#include <string>
using namespace std;

#define ll long long
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);

ll MOD = 1e9 + 7;

ll fastPower(ll x, ll n) {
    ll ans = 1;
    while(n > 0) {
        if(n % 2 == 1) ans = ans * x;
        x = x * x;
        n /= 2;
    }
    return ans;
}

set<ll> divisors(ll n) 
{ 
    set<ll> res;
    for (int i=1; i * i<=n; i++) { 
        if (n%i == 0) { 
            res.insert(i);
            res.insert(n / i);
        } 
    } 
    return res;
} 

vector<ll> primeFact(ll n) {
    vector<ll> res;
    for(ll i=2; i * i <= n; ++i) {
        while(n % i == 0) {
            res.push_back(i);
            n /= i;
        }
    }
    if(n != 1) res.push_back(n);
    return res;
}

ll gcd(ll a,ll b) {
  ll R;
  while ((a % b) > 0)  {
    R = a % b;
    a = b;
    b = R;
  }
  return b;
}

string decimalToBinary(ll n) {
    string binary = "";
    while (n > 0) {
        binary = to_string(n % 2) + binary;
        n /= 2;
    }
    return binary;
}

void solve(vector<ll> v) {
    ll n = v.size();
    ll ans = 0;
    ll cur = 0;
    for(ll i=0; i<n; ++i) {
        ans += v[i];
    }
    ans = abs(ans);
    if(n == 1) {
        cout << v[0] << "\n";
        return;
    }
    while(n > 1) {
        vector<ll> v2;
        cur = 0;
        for(ll i=0; i<n - 1; ++i) {
            ll num1 = v[i + 1];
            ll num2 = v[i];
            ll dif = num1 - num2;
            v2.push_back(dif);
            cur += abs(dif);
        }
        v.clear();
        for(ll i=0; i<n - 1; ++i) {
            v.push_back(v2[i]);
        }
        v2.clear();
        n--;
        ans = max(ans, cur);
    }
    cout << ans << "\n";
}

int main() {
    fastio;
    ll t;
    cin >> t;
    while(t--) {
        ll n;
        cin >> n;
        vector<ll> v;
        for(ll i=0; i<n; ++i) {
            ll a;
            cin >> a;
            v.push_back(a);
        }
        solve(v);
    }
    return 0;
}