Problem: 2062C - Cirno and Operations
Language: java

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

public class Code {

    // Input and Output
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static PrintWriter out = new PrintWriter(System.out);

    // For parsing integers, longs, and strings efficiently
    static StringTokenizer st;

    // Entry point
    public static void main(String[] args) throws IOException {
        int t; // Number of test cases
        t = nextInt(); // Uncomment this line if multiple test cases
        while (t-- > 0) {
            solve(); // Call the solve function for each test case
        }
        out.close(); // Close the output stream
    }

    // Solve function for each test case

    static void solve() throws IOException {
        int n = nextInt();
        long[] arr = new long[n];

        for(int i=0;i<n;i++){
            arr[i] = nextLong();
        }

        int now = n;
        long ans = Long.MIN_VALUE;

        for(int i=0;i<n;i++) {
            long sum = 0L;
            for (int j = 0; j < now; j++) {
                sum += arr[j];
            }

            if(i==0){
                ans = Math.max(ans, sum);
            }
            else{
                ans = Math.max(ans, Math.abs(sum));
            }

            for(int j = 0;j<now-1;j++){
                arr[j] = arr[j+1] - arr[j];
            }
            now--;
        }

        out.println(ans);
    }

    // Utility methods for faster input
    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    char nextChar() {
        try {
            return (char) br.read();
        } catch (IOException e) {
            e.printStackTrace();
            return '\0'; // Return null character in case of an error
        }
    }

    static String nextLine() throws IOException {
        return br.readLine();
    }

    // Utility functions
    static int gcd(int a, int b) {
        if (b == 0) return a;
        return gcd(b, a % b);
    }

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

    static boolean isPrime(int n) {
        if (n <= 1) return false;
        if (n <= 3) return true;
        if (n % 2 == 0 || n % 3 == 0) return false;
        for (int i = 5; i * i <= n; i += 6) {
            if (n % i == 0 || n % (i + 2) == 0) return false;
        }
        return true;
    }

    static long power(long x, long y, long p) {
        long res = 1;
        x = x % p;
        while (y > 0) {
            if ((y & 1) == 1)
                res = (res * x) % p;
            y = y >> 1;
            x = (x * x) % p;
        }
        return res;
    }

    public static void sort(int[] arr)
    {
        //because Arrays.sort() uses quicksort which is dumb
        //Collections.sort() uses merge sort
        ArrayList<Integer> ls = new ArrayList<Integer>();
        for(int x: arr)
            ls.add(x);
        Collections.sort(ls);
        for(int i=0; i < arr.length; i++)
            arr[i] = ls.get(i);
    }
}


Solution 2 (runtime: 140 ms):
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException {
        InputReader scan = new InputReader(System.in);
        PrintWriter pw = new PrintWriter(System.out);

        int t = scan.nextInt();
        while (t --> 0) {
            int n = scan.nextInt();
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = scan.nextLong();
            }

            long maxSum = 0;
            for (int i = 0; i < n; i++) {
                maxSum += a[i];
            }

            for (int i = 0; i < n-1; i++) {
                long sum = 0;
                for (int j = 0; j < n-i-1; j++) {
                    a[j] = a[j+1] - a[j];
                    sum += a[j];
                }
                maxSum = Math.max(maxSum, Math.abs(sum));
            }

            pw.println(maxSum);
        }

        pw.close();
    }
    static class InputReader {

        private final InputStream stream;
        private final byte[] buf = new byte[8192];
        private int curChar, snumChars;
        private SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int snext() {
            if (snumChars == -1)
                throw new InputMismatchException();
            if (curChar >= snumChars) {
                curChar = 0;
                try {
                    snumChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (snumChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = snext();
            while (isSpaceChar(c))
                c = snext();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = snext();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = snext();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public long nextLong() {
            int c = snext();
            while (isSpaceChar(c))
                c = snext();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = snext();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = snext();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public int[] nextIntArray(int n) {
            int a[] = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public String readString() {
            int c = snext();
            while (isSpaceChar(c))
                c = snext();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = snext();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }
}