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

Solution 1 (runtime: 46 ms):
#include <bits/stdc++.h>
using namespace std;


#define ll long long int
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<pii>
#define F first
#define S second
#define sz(x) ((int)(x).size())
#define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int MOD = 1e9 + 7;
const ll INF = 1e18;


template<typename T>
void debug(vector<T> v) { for(auto i: v) cout << i << " "; cout << endl; }

template<typename T1, typename T2>
void debug(vector<pair<T1, T2>> v) { for(auto i: v) cout << "(" << i.F << "," << i.S << ") "; cout << endl; }


int main() {
    fast_io;

    int t;
    cin >> t;
    while (t--) {
        int n;
        cin >> n;
        vll a(n);
        ll sum =0;
        for(int i=0;i<n;i++){
            cin>>a[i];
            sum+=a[i];
        }

        ll ans = sum;
        int e = n;
        for(int i=0;i<n-1;i++){
            sum = 0;
            for(int i=1;i<e;i++){
                sum+=(a[i] - a[i-1]);
                a[i-1] = (a[i]  -a[i-1]);
            }
            e--;
            ans = max(ans,abs(sum));
        }

        cout<<ans<<endl;
        
    }

    return 0;
}

Solution 2 (runtime: 202 ms):
#include <iostream>
#include<bits/stdc++.h>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include<algorithm>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define IOF ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
#define ll long long
#define ld long double
#define cy cout << "YES" << '\n';
#define cn cout << "NO" << '\n';
using namespace std;
using namespace __gnu_pbds;

template<class T> using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int dx[] = {1, 0, -1, 0, -1, -1, 1, 1};
int dy[] = {0, -1, 0, 1, -1, 1, -1, 1};
int knightX[] = {-2, -2, 2, 2, 1, 1 , -1, -1};
int knighty[] = {-1, 1, -1, 1, -2, 2, -2, 2};
char di[] = {'D', 'L', 'U', 'R'};
const int N =3e5+5;
const ll MOD = 1e9+7;
void FOI(){
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w" , stdout);
}

//check ur idea
ll maxi;
map<pair<vector<ll> , bool> , int> vis;
void calc(vector<ll> v , bool is){
    maxi = max(maxi , accumulate(v.begin() , v.end() , 0LL));
    if(v.size() == 1)return ;

    if(vis[{v , is}])return ;
    vis[{v , is}] = 1;
    if(!is)
    {   vector<ll> tmp = v;
        reverse(tmp.begin() , tmp.end());
        calc(tmp , true);}
    vector<ll> tmp;
    for(int i = 1 ; i < v.size() ; i++){
        tmp.push_back(v[i] - v[i-1]);
    }
    calc(tmp , false);

}

void solve(){
maxi = -1e18;
int n ; cin >> n;
vector<ll> v(n) ; 
for(int i = 0 ; i < n ; i++)cin >> v[i];
calc(v , false);
cout << maxi  << '\n';
vis.clear();
}



int main() {
 

    IOF
    ll t = 1;
    cin >> t;
    while (t--) {
    solve() ;

    }
 
    return 0;
}