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

Solution 1 (runtime: 46 ms):
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <climits>
#include <numeric>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define tcT template<class T
tcT> using ordered_set = tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>;
using ll = long long;
using db = long double;
using str = string;
using pi = pair<int,int>;
using pll = pair<ll,ll>;
using ppi = pair<int,pair<int,int>>;
#define mp make_pair
#define pb push_back
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fe(i,a,b) for(ll i=a;i<=b;i++)
#define ff(i,a,b) for(ll i=b-1;i>=a;i--)
#define each(a,x) for (auto& a: x)
#define rall(x) x.rbegin(),x.rend()
#define all(x) x.begin(),x.end()
#define PYES cout<<"YES"<<endl
#define PNO cout<<"NO"<<endl
#define PYes cout<<"Yes"<<endl
#define PNo cout<<"No"<<endl
#define tcT template<class T
tcT> using V = vector<T>; 
tcT, size_t SZ> using AR = array<T,SZ>;
using vi = V<int>;
using vvi = V<vi>;
using vll = V<ll>;
using vvll = V<vll>;
using vb = V<bool>;
using vvb = V<vb>;
using vpi = V<pi>;
using vpll = V<pll>;
//const int MOD = 1e9+7;
//const db PI = acos((db)-1);
//mt19937 rng(0); // or mt19937_64
//const ll inf = LLONG_MAX;
//const int inf = INT_MAX;


void solve(){
    int n;
    cin >> n;
    vll arr;
    f(i, 0, n)
    {
        ll i1;
        cin >> i1;
        arr.pb(i1);
    }
    
    //cout << "ans" << ans << endl;
    int n2 = n;
    ll ans, sum;
    ans = -LLONG_MAX;
    f(i, 0, n)
    {
        sum = 0;
        
        f(j, 0, n2)
        {
            sum += arr[j];
        }
        if(i == 0){ans = max(ans, sum);}
        else ans = max(ans, abs(sum));

        f(j, 0, n2)
        {
            arr[j] = arr[j+1] - arr[j];
        }

        n2--;
    }

    cout << ans<< endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin >> t;
    // t=1;
    while (t--)
    {
        solve();
    }
    return 0;
}

Solution 2 (runtime: 46 ms):
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define vi vector<ll> 
#define vvi vector<vi>
#define umi unordered_map<ll,ll>
#define usi unordered_set<ll> 
#define all(x) x.begin(),x.end()
#define fr(i, n) for (long long i = 0; i < (n); i++)
using namespace std;

const ll mod = 1e9+7;

vector<ll>sol(vector<ll> v) {
  ll n=v.size();
  vi ki;
  for(ll i=1;i<n;i++){
    ki.pb(v[i]-v[i-1]);
  }
  ll sm=accumulate(all(ki),0LL);
  if(sm<0){
    reverse(all(v));
    ki.clear();
    for(ll i=1;i<n;i++){
       ki.pb(v[i]-v[i-1]);
    }
  }
  return ki;
}

void solve() {
    ll n;
    cin >> n;
    vi v(n);
    fr(i, n) {
        cin >> v[i];
    }ll mx=INT_MIN;ll si=accumulate(all(v),0LL);
 while(!v.empty()){
    ll sm=accumulate(all(v),0LL);
    v=sol(v);
    mx=max(mx,sm);
}
cout<<max(mx,si)<<endl;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll tt = 1;
    cin >> tt;
    while (tt--) {
        solve();
    }
}