Problem: 2062C - Cirno and Operations
Language: java

Solution 1 (runtime: 249 ms):
import java.util.*;
import java.io.*;
import java.math.*;

public class sub {

	// can i get expert by summer please

	static int mod = 998244353;

	public static void main(String args[]) throws IOException {
		int t = sc.nextInt();
		while (t-- > 0) {
			int n = sc.nextInt();
			ArrayList<Long> a = new ArrayList();
			if (n == 1) {
				out.println(sc.nextInt());
			} else {
				long ans = 0;
				for (int i = 0; i < n; i++) {
					a.add(sc.nextLong());
					ans+=a.get(i);
				}
				for (int i = 1; i < n; i++) {
					ArrayList<Long> copy = new ArrayList();
					for(int j = 0;j<a.size()-1;j++) {
						copy.add(a.get(j) - a.get(j + 1));
					}
					a=copy;
					long sum = 0;
					for (int j = 0; j < a.size(); j++) {
						sum += a.get(j);
					}
					if(sum<0) {
						Collections.reverse(a);
					}
					
					ans=Math.max(ans,Math.abs(sum));
				}
				out.println(ans);
			}
		}
		out.close();
	}

//	static long bincoef(int n, int k) {
//	    if (n < k) return 0L;
//	    return (p[n] * pow((p[n - k] * p[k]) % mod, mod - 2, mod)) % mod;
//	}

	static long pow(long a, long b, long mod) {
		if (b == 0) {
			return 1L;
		}
		long val = pow(a, b / 2, mod);
		if (b % 2 == 0) {
			return val * val % mod;
		}
		return val * val % mod * a % mod;
	}

	static long gcd(long a, long b) {
		if (b == 0) {
			return a;
		}
		return gcd(b, a % b);
	}

	static long lcm(long a, long b) {
		return a * b / gcd(a, b);
	}

	static Kattio sc = new Kattio();
	static PrintWriter out = new PrintWriter(System.out);

	static class Kattio {

		static BufferedReader r;
		static StringTokenizer st;

		public Kattio() {
			r = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() {
			try {
				while (st == null || !st.hasMoreTokens()) {
					st = new StringTokenizer(r.readLine());
				}
				return st.nextToken();
			} catch (Exception e) {
				return null;
			}
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}
	}
}

Solution 2 (runtime: 312 ms):
import java.util.*;
public class cirnoop2
{
   public static void main(String args[])
   {
       Scanner in = new Scanner(System.in);
       int t=in.nextInt();
       while(t!=0)
       {
           t--;
           int n=in.nextInt();
           long arr[]=new long[n];
           int i,j;
           long s=0,max=0;
           
           for(i=0;i<n;i++)
           {
               arr[i]=in.nextInt();
               s=s+arr[i];
           }
           if(n==1)
           {
               System.out.println(arr[0]);
           }          
           else
           {
           
           max=Math.max(s,-(long)Math.pow(10,18));
           while(n>=1)
           {
               
               
               --n;
               
               s=0;
               
               for(i=0;i<n;i++)
               {
                   arr[i]=arr[i+1]-arr[i];
                   s=s+arr[i];
               }
               arr[n]=0;
               
              
               s=Math.abs(s);
               max=Math.max(s,max);
           }
           System.out.println(max);
           }
           
   }
}
}