Language: C++

#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < n; ++i)
#define REPR(i,n) for(int i = n; i >= 0; --i)
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = b-1;i >= a;--i)
#define p(s) cout << (s) << endl
#define p2(s,t) cout << (s) << " " << (t) << endl 
#define ALL(v) (v).begin(), (v).end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;
using namespace std;

static const ll MOD  = 1e9 + 7;
static const ll INF  = 1e18;

static const int White = 0;
static const int Gray = 1;
static const int Black = 2;

void pvector(vector<int> A){
    cout << "[vector]";
    for(int i = 0; i < A.size(); i++){
        cout << A[i] << " ";
    }
    cout << endl;
}

int main(){
    ll N;
    cin >> N;
    ll A[N];
    for(int i = 0; i < N;i++){
        cin >> A[i];
    }
    sort(ALL(A));
    int *pos = lower_bound(ALL(A), 0);
    int idx = distance(A, pos);
    ll sum = 0;
    if(idx == N){
        int tmp = A[N-1];
        for(int i = 0; i < N-1; i++){
            sum -= A[i];
        }
        sum += A[N-1];
        cout << sum << endl;
        for(int i = N-2; i >= 0; i--){
            cout << tmp << " ";
            tmp -= A[i];
            cout << A[i] << endl;
        }
    }else if(idx == 0){
        int tmp = A[0];
        for(int i = 1; i < N; i++){
            sum += A[i];
        }
        sum -= A[0];
        cout << sum << endl;
        for(int i = 1; i <=  N-2; i++){
            cout << tmp << " ";
            tmp -= A[i];
            cout << A[i] << endl;
        }
        cout << A[N-1] << " " << tmp << endl;
    }else{
        int tmp = A[idx-1];
        for(int i = 0; i < N; i++){
            sum += A[i];
        }
        cout << sum << endl;
        for(int i = idx; i <= N-2; i++){
            cout << tmp << " ";
            tmp -= A[i];
            cout << A[i] << endl;
        }
        cout << A[N-1] << " " << tmp  << endl; 
        tmp = A[N-1] - tmp;
        for(int i = 0; i <= idx-2; i++){
            cout << tmp << " ";
            tmp -= A[i];
            cout << A[i] << endl;
        }

    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:20: error: request for member 'begin' in 'A', which is of non-class type 'll [N]' {aka 'long long int [N]'}
    8 | #define ALL(v) (v).begin(), (v).end()
      |                    ^~~~~
a.cc:35:10: note: in expansion of macro 'ALL'
   35 |     sort(ALL(A));
      |          ^~~
a.cc:8:33: error: request for member 'end' in 'A', which is of non-class type 'll [N]' {aka 'long long int [N]'}
    8 | #define ALL(v) (v).begin(), (v).end()
      |                                 ^~~
a.cc:35:10: note: in expansion of macro 'ALL'
   35 |     sort(ALL(A));
      |          ^~~
a.cc:8:20: error: request for member 'begin' in 'A', which is of non-class type 'll [N]' {aka 'long long int [N]'}
    8 | #define ALL(v) (v).begin(), (v).end()
      |                    ^~~~~
a.cc:36:28: note: in expansion of macro 'ALL'
   36 |     int *pos = lower_bound(ALL(A), 0);
      |                            ^~~
a.cc:8:33: error: request for member 'end' in 'A', which is of non-class type 'll [N]' {aka 'long long int [N]'}
    8 | #define ALL(v) (v).begin(), (v).end()
      |                                 ^~~
a.cc:36:28: note: in expansion of macro 'ALL'
   36 |     int *pos = lower_bound(ALL(A), 0);
      |                            ^~~
a.cc:37:23: error: no matching function for call to 'distance(ll [N], int*&)'
   37 |     int idx = distance(A, pos);
      |               ~~~~~~~~^~~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:148:5: note: candidate: 'template<class _InputIterator> constexpr typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::distance(_InputIterator, _InputIterator)'
  148 |     distance(_InputIterator __first, _InputIterator __last)
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:148:5: note:   template argument deduction/substitution failed:
a.cc:37:23: note:   deduced conflicting types for parameter '_InputIterator' ('long long int*' and 'int*')
   37 |     int idx = distance(A, pos);
      |               ~~~~~~~~^~~~~~~~
In file included from /usr/include/c++/14/filesystem:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200:
/usr/include/c++/14/bits/fs_path.h:1431:1: note: candidate: 'std::ptrdiff_t std::distance(filesystem::__cxx11::path::iterator, filesystem::__cxx11::path::iterator)'
 1431 | distance(filesystem::path::iterator __first, filesystem::path::iterator __last)
      | ^~~~~~~~
/usr/include/c++/14/bits/fs_path.h:1431:37: note:   no known conversion for argument 1 from 'll [N]' {aka 'long long int [N]'} to 'std::filesystem::__cxx11::path::iterator'
 1431 | distance(filesystem::path::iterator __first, filesystem::path::iterator __last)
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~