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

Solution 1 (runtime: 62 ms):
//#include<do4z.h>
#include"bits/stdc++.h"
#define fastt ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
using namespace std;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using ord_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//do less_equal in place of less to convert into multiset
//for converting into map, write pair<class T ,class S> instead of class T
#define int long long
int32_t main()
{
    fastt;
    int t=1;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        vector<int>a(n);
        for(auto &i:a) cin>>i;
        int ans3=INT_MIN;
        while(a.size()>1)
        {
            n=a.size();
            int ans1=0,ans2=0;
            ans3=max(ans3,accumulate(a.begin(),a.end(),0ll));
            for(int i=1;i<n;i++) ans1+=a[i]-a[i-1];
            for(int i=n-1;i>0;i--) ans2+=a[i-1]-a[i];
            vector<int>temp;
            if(ans2>ans1) reverse(a.begin(),a.end());
            for(int i=1;i<n;i++) temp.push_back(a[i]-a[i-1]);
            a=temp;
        }
        cout<<max(a[0],ans3)<<"\n";
    }
    return 0;
}
/*
Ahhhhh shitttt, here we go again..
*/

Solution 2 (runtime: 46 ms):
#include <bits/stdc++.h>
#include<conio.h>
#define whc long long int
#define whl ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define nl "\n"
using namespace std;
vector<whc> divisor(whc n)
{
    vector<whc> div;
    whc i;
    for(i=1;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
            if(n/i==i)
                div.push_back(i);
            else
                div.push_back(i),div.push_back(n/i);
        }
    }
    sort(div.begin(),div.end());
    return div;
}
bool is_prime(whc n)
{
    if(n==1)
        return false;
    whc i;
    i=2;
    while(i*i<=n)
    {
        if (n%i==0)
            return false;
        i+=1;
    }
    return true;
}
whc distance(whc x1,whc y1,whc x2,whc y2)
{
    return (((x2-x1)*(x2-x1))+((y2-y1)*(y2-y1)));
}
whc lcm(vector<whc> vec)
{
    whc x=2,i,m,r=1;
    sort(vec.begin(),vec.end());
    m=vec[vec.size()-1];
    while(x<=m)
    {
        vector<whc> cnt;
        for(i=0;i<vec.size();i++)
        {
            if(vec[i]%x==0)
                cnt.push_back(i);
        }
        if(cnt.size()>=2)
        {
            for(i=0;i<cnt.size();i++)
                vec[cnt[i]]/=x;
            r*=x;
        }
        else
            x++;
    }
    for(i=0;i<vec.size();i++)
        r*=vec[i];
    return r;
}
int main()
{
    whl
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    whc t;
    cin>>t;
    //t=1;
    while(t--)
    {
        whc n,s=-1e18,i,j,m,a;
        cin>>n;
        vector<whc> vec(n+1);
        for (i=1;i<=n;i++)
            cin>>vec[i];
        m=n;
        for(j=1;j<=n;j++)
        {
            a=0;
            for(i=1;i<=m;i++)
                a+=vec[i];
            if(j==1)
                s=max(s,a);
            else
                s=max(s,max(a,(-a)));
            for(i=1;i<m;i++)
                vec[i]=(vec[i+1]-vec[i]);
            m--;
        }
        cout<<s<<nl; 
    }
}