Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
  long long n,k=0,l=0;
  vector<long long> mna,mnb;
  cin >> n;
  long long a[n];
  for(long long i=0LL; i<n; i++){
    cin >> a[i];
  }
  sort(a,a+n);
  if(a[0]==1LL){
    cout<<"1\n";
    return 0;
  }
  mna[k]=a[0];
  for(long long i=1LL; i<n; i++){
    if(a[i]%a[0]){
      if(a[i]%a[0]==1){
        cout<<"1\n";
        return 0;
      }
      bool fl=true;
      for(long long j=0LL; j<=k; j++){
        if(mna[j]==a[i]%a[0])fl=false;
      }
      if(fl){
        k++;
        mna[k]=a[i]%a[0];
      }
    }
  }
  cout<<solve(mna,mnb,k,l)<<endl;
  return 0;
}
long long solve(vector<long long> A, vector<long long> B, long long aL, long long bL){
  if(aL==0)return A[0];
  sort(A.begin,A.end);
  if(A[0]==1)return 1;
  if(bL)B.clear();
  bL=0;
  B[0]=A[0];
  for(long long i=1LL; i<=aL; i++){
    if(A[i]%A[0]){
      if(A[i]%A[0]==1)return 1;
      bool fl=true;
      for(long long j=0LL; j<=bL; j++){
        if(B[j]==A[i]%A[0])fl=false;
      }
      if(fl){
        bL++;
        B[bL]=A[i]%A[0];
      }
    }
  }
  return solve(B, A, bL, aL);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:9: error: 'solve' was not declared in this scope
   35 |   cout<<solve(mna,mnb,k,l)<<endl;
      |         ^~~~~
a.cc: In function 'long long int solve(std::vector<long long int>, std::vector<long long int>, long long int, long long int)':
a.cc:40:7: error: no matching function for call to 'sort(<unresolved overloaded function type>, <unresolved overloaded function type>)'
   40 |   sort(A.begin,A.end);
      |   ~~~~^~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h:4762:5: note: candidate: 'template<class _RAIter> void std::sort(_RAIter, _RAIter)'
 4762 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:4762:5: note:   template argument deduction/substitution failed:
a.cc:40:7: note:   couldn't deduce template parameter '_RAIter'
   40 |   sort(A.begin,A.end);
      |   ~~~~^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4793:5: note: candidate: 'template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter, _Compare)'
 4793 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:4793:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator, class _Compare> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _Compare)'
  292 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note:   candidate expects 4 arguments, 2 provided
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator)'
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note:   candidate expects 3 arguments, 2 provided