Language: C++

/**
                  ▄█▀ ▀█▀ ▄▀▄ █▀ █▄█▄█ ▄▀▄ █▀ ▄█▀
                  <⇋⇋⇋⋛∰≓⊂(⌒,_ゝ⌒)⊃≓∰⋛⇋⇋⇋>

            ♔♕♖♗♘♙ ☜❷☞✪ ィℋ६ ≈ ᗫẵℜℵĬŊĞ ✪☜❷☞ ♚♛♜♝♞♟
            ♔♕♖♗♘♙                             ♚♛♜♝♞♟
                      ˙·٠•●♥ Ƹ̵̡Ӝ̵̨̄Ʒ ♥●•٠·˙

**/

#include <bits/stdc++.h>

#define sz(s) s.size()
#define pb emplace_back
#define fr first
#define sc second
#define mk make_pair
#define int long long
#define all(s) s.begin(), s.end()

using namespace std;

const int N = 2e5 + 5;
const int inf = 1e9 + 7;

int n, sum, a[N];
vector < int > b;
vector < pair < int, int > > s;

main()
{
   cin >> n;
   for( int i = 1; i <= n; i++ )
      cin >> a[i], b.pb( a[i] );

   sort( all( b ) );

//   cout << lower_bound( all( b ), 100 / 2 ) - b.begin() << endl;

   for( int i = 1; i <= n; i++ )
   {
      int pos = lower_bound( all( b ), a[i] / 2 ) - b.begin() - 3;
      pos = max( 0, pos );
      int p = inf, l = 0;
      for( int j = pos; j <= min( pos + 3, n - 1 ); j++ )
         if( abs( a[i] - b[ j ] - b[ j ] ) < p )
            l = b[ j ], p = abs( a[i] - b[ j ] - b[ j ] );
      s.pb( mk( a[i], l ) );
   }
   pair < int, int > v, q;
   sort( all( s ) );
   v = s[ sz(s) - 1 ];
   cout << v.fr << ' ' << v.sc << endl;
}

Compiler output:
a.cc:30:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   30 | main()
      | ^~~~
a.cc: In function 'int main()':
a.cc:43:16: error: no matching function for call to 'max(int, long long int&)'
   43 |       pos = max( 0, pos );
      |             ~~~^~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:11:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:43:16: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   43 |       pos = max( 0, pos );
      |             ~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:43:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   43 |       pos = max( 0, pos );
      |             ~~~^~~~~~~~~~