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

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

int main()
{
    int l,t;
    cin>>t;
    while(t--){
    cin>>l;
    long long int arr[l];
    long long int s=0;
    for(int i=0;i<l;i++) cin>>arr[i];
    for(int i=0;i<l;i++) s=s+arr[i];
    long long int s1=0;
    while(l>1){
        s1=abs(arr[l-1]-arr[0]);
        if(s1>s) s=s1;
        for(int i=0;i<l-1;i++) arr[i]=arr[i+1]-arr[i];
        l--;
    }
    cout<<s<<"\n";
    }

    return 0;
}

Solution 2 (runtime: 46 ms):
// DO NOT COPY AND PASTE CODE
// Be very sure of what you are doing before submitting
// Solve 1000+ problems of rating range 1300-1800 (400+ of 1300-1500 and 600+ for 1600-1800) before 31st December.
// Analyze the ratings of problems you are solving here https://cfviz.netlify.app/
// Dont look at test cases
#include<bits/stdc++.h>
using namespace    std;
#include <iostream>
#include <algorithm> 

#include<numeric>
// typedef long ;
// #include <iostream>
// #include <cstdlib>
// #include <ctime>
// #include <thread>
// #include <chrono>
// #include <iostream>

// // Library effective with Windows
// #include <windows.h>

// // Library effective with Linux
// #include <unistd.h>
// const ll INF = 1e9+7;





#define ll                  long long 
#define ull                 unsigned long long
// #define MOD                 1000000007 // 998244353
#define vi                  vector<int>
#define vb                  vector<bool>
#define vvi                 vector<vector<int> >
#define vll                 vector<long long>
#define pb                  push_back
#define eb                  emplace_back
#define mp(a, b)            make_pair(a, b)
#define pii                 pair<int, int>
#define vpii                vector<pair<int, int> >
#define mk(arr, n, type)    type *arr = new type[n];
#define FOR(i, a, b)        for (int(i) = (a); (i) < (b); ++(i))
#define RFOR(i, a, b)       for (int(i) = (a)-1; (i) >= (b); --(i))
#define FORALL(i, a)        for (auto& (i) : (a))
#define printall(a)         for (auto& (i) : (a)) cout << i << ' '
#define print(a)            cout << a << '\n'
#define rsort(a)            sort((a).rbegin(), (a).rend())
#define w(x)                int x; cin >> x; while(x--)
#define all(c)              (c).begin(), (c).end()
#define sz(c)               (int)(c).size()
#define pqmx                priority_queue<int>
#define pqmn                priority_queue<int, vector<int>, greater<int> >
#define max3(a, b, c)       max((a), max((b), (c)))
#define min3(a, b, c)       min((a), min((b), (c)))
#define mx_all(c)           *max_element((c).begin(), (c).end())
#define mn_all(c)           *min_element((c).begin(), (c).end())
#define lwr_b(c, a)         lower_bound((c).begin(), (c).end(), (a)) - ((c).begin())
#define upr_b(c, a)         upper_bound((c).begin(), (c).end(), (a)) - ((c).begin())
#define FIO                 ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
// #define MAXN 100010
// int x[MAXN],y[MAXN],a[MAXN],degree[MAXN];
// const int MAX = 100'007;
const long long int MOD = 1000000007;

bool isprime(long long int N){
    if(N<2 || (!(N&1) && N!=2))
        return 0;
    for(int i=3; i*i<=N; i+=2){
        if(!(N%i))
            return false;
    }
    return true;
}

long long int factorial(long long int n) {
    if (n <= 1) {  
        return 1;
    } else {
        return (n * factorial(n - 1));  
    }
}

void upd(int &a, int b) {
    a = (a * 1LL * b) % MOD;
}
// #define sz(a) int((a).size())
// #define forn(i, n) for (int i = 0; i < int(n); ++i)

long long int gcd(long long int a, long long int b) {
    while (b != 0) {
        long long int temp = b;
        b = a % b;  // Get the remainder
        a = temp;   // Update a to the previous value of b
    }
    return a;
}

long long int powerMod(long long int base, long long int exponent, long long int mod) {
    long long int result = 1;
    base = base % mod;    

    while (exponent > 0) {
        if (exponent % 2 == 1) {
            result = (result * base) % mod;
        }
        exponent = exponent >> 1;  
        base = (base * base) % mod; 
    }

    return result;
}


double roundToSixDecimalPlaces(double value) {
    return std::round(value * 1e6) / 1e6;
}
vector<ll> parent,component;

ll find(ll x){
    if(x==parent[x]) return x;
    return parent[x]=find(parent[x]);
}

void unite(ll a, ll b){
    a=find(a);
    b=find(b);
    if(a!=b){
        if(component[a]<component[b]){
            swap(a,b);
        }
        parent[b]=a;
        component[a]+=component[b];
    }
}


ull ull_abs(ull a, ull b) {
    return (a > b) ? (a - b) : (b - a);
}

const int MAXN = 200200;


void dfsRecursive(int vertex, vector<bool>& visited, const vector<vector<int>>& adjList) {
    visited[vertex] = true;  

    for (int neighbor : adjList[vertex]) {
        if (!visited[neighbor]) {
            dfsRecursive(neighbor, visited, adjList);
        }
    }
}


long long power(long long a, long long b)
{
    long long res = 1;
    while (b > 0) {
        if (b%2==1) {
            res = (res * a);
        }
        a*=a;
        b >>= 1;
    }
    return res;
}

long long lcm(int a, int b) {
    return (1LL * a * b) / __gcd(a, b);
}

int pb, pc, ps;
int nb, nc, ns;
int lb, lc, ls;
ll fb, fc, fs;

ll price(ll x)
{
    fb = max(x*lb - nb, (ll)0);
    fc = max(x*lc - nc, (ll)0);
    fs = max(x*ls - ns, (ll)0);

    ll p = fb*pb + fc*pc + fs*ps;
    return p;
}

void solve() {
    int n;
    cin>>n;
    long long int curr_sum=0,sum_diff=0,sum_diff_reversed=0;
    // vector<int> vec(n+1,0);
    long long vec[1010];
    for(int i=1;i<=n;i++){
        cin>>vec[i];
        curr_sum+=vec[i];}
    int now = n;
        long long ans = -1e18;
        for (int i = 1; i <= n; i++){
            long long sum = 0;
            for (int i = 1; i <= now; i++) sum = (sum + vec[i]) ;
            if (i == 1) ans = max(ans, sum);
            else ans = max(ans, max(sum, ( - sum) ));
            for (int i = 1; i < now; i++) vec[i] = (vec[i + 1] - vec[i]) ;
            now--;
        }
        cout << ans << endl; 
    
    

}

int main(){
   int t;
   cin>>t;
   while(t--){
    solve();
   }
    
   return 0;
}
;