Language: Java

import javafx.util.Pair;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        StringTokenizer st = new StringTokenizer(br.readLine());
        List<Integer> pos = new ArrayList<>();
        List<Integer> neg = new ArrayList<>();
        long sumPos;
        long sumNeg;
        ArrayList<Pair<Long, Long>> pair = new ArrayList<>();
        for(int i=0;i<n;i++) {
            int temp = Integer.parseInt(st.nextToken());
            if (temp >= 0) {
                pos.add(temp);
            } else {
                neg.add(temp);
            }
        }
            Collections.sort(pos);
            Collections.sort(neg);
            Collections.reverse(neg);
            sumPos = (neg.size()==0)? pos.get(0):neg.get(0);
            sumNeg=(pos.size()==0)?neg.get(0):pos.get(0);
            if(pos.size()>0) {
                for (int i = 1; i < pos.size() - 1; i++) {
                    pair.add(new Pair<>(sumPos, (long) pos.get(i)));
                    sumPos -= pos.get(i);
                }
                if (neg.size() == 0) {
                    pair.add(new Pair<>((long) pos.get(pos.size() - 1), sumPos));
                    sumPos = pos.get(pos.size() - 1) - sumPos;

                    System.out.println(sumPos);
                    for (Pair p : pair) {
                        System.out.println(p.getKey() + " " + p.getValue());
                    }
                    return;
                }
            }
            if(neg.size()>0){
                for(int i=1; i<neg.size(); i++){
                    pair.add(new Pair<>(sumNeg, (long)neg.get(i)));
                    sumNeg-=neg.get(i);
                }
                if(pos.size()==0){
                    System.out.println(sumNeg);
                    for (Pair p : pair) {
                        System.out.println(p.getKey() + " " + p.getValue());
                    }
                    return;
            }
            else {
                if(pos.size()>1)
                    pair.add(new Pair<>(sumPos, (long) pos.get(pos.size()-1)));
                    sumPos -= pos.get(pos.size()-1);
            }
                pair.add(new Pair<>(sumNeg,sumPos));
                System.out.println(sumNeg-sumPos);
                for(Pair p: pair){
                    System.out.println(p.getKey() + " " + p.getValue());
                }
        }
    }
}

Compiler output:
Main.java:1: error: package javafx.util does not exist
import javafx.util.Pair;
                  ^
Main.java:20: error: cannot find symbol
        ArrayList<Pair<Long, Long>> pair = new ArrayList<>();
                  ^
  symbol:   class Pair
  location: class Main
Main.java:36: error: cannot find symbol
                    pair.add(new Pair<>(sumPos, (long) pos.get(i)));
                                 ^
  symbol:   class Pair
  location: class Main
Main.java:40: error: cannot find symbol
                    pair.add(new Pair<>((long) pos.get(pos.size() - 1), sumPos));
                                 ^
  symbol:   class Pair
  location: class Main
Main.java:44: error: cannot find symbol
                    for (Pair p : pair) {
                         ^
  symbol:   class Pair
  location: class Main
Main.java:52: error: cannot find symbol
                    pair.add(new Pair<>(sumNeg, (long)neg.get(i)));
                                 ^
  symbol:   class Pair
  location: class Main
Main.java:57: error: cannot find symbol
                    for (Pair p : pair) {
                         ^
  symbol:   class Pair
  location: class Main
Main.java:64: error: cannot find symbol
                    pair.add(new Pair<>(sumPos, (long) pos.get(pos.size()-1)));
                                 ^
  symbol:   class Pair
  location: class Main
Main.java:67: error: cannot find symbol
                pair.add(new Pair<>(sumNeg,sumPos));
                             ^
  symbol:   class Pair
  location: class Main
Main.java:69: error: cannot find symbol
                for(Pair p: pair){
                    ^
  symbol:   class Pair
  location: class Main
10 errors