Language: C++

//まともに使い方を理解していないくせにincludeしまくる人間のクズ
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <set>
//#include <map>
#include <bitset>
#include <iostream>


//using namespace stdしないと表記がめんどくさいからね、仕方ないね
using namespace std;

//可読性を上げるためのdefineが仇となる典型的パターン
#define rep(i,n) for(int i = 0; i < x; i++)

//ローカル変数とグローバル変数は使い分けよう！
stack<short> x, y;
long long int ans, n, array[5000];

//関数って楽しいよね！（魔王スマイル）

void solve(long long int sum, short i){
    if(ans < sum) ans = sum;
    if(i == n) return;
    solve(sum + array[i], i + 1);
    solve(0, i + 1);
}

int main(){
    while(true){
        scanf("%lld", &n);
        if(n == 0) return 0;
        ans = 0;
        rep(i,n) scanf("%lld", &array[i]);
        solve(0, 0);
        printf("%lld\n", ans);
    }
}

Compiler output:
a.cc: In function 'void solve(long long int, short int)':
a.cc:33:17: error: reference to 'array' is ambiguous
   33 |     solve(sum + array[i], i + 1);
      |                 ^~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/bits/specfun.h:43,
                 from /usr/include/c++/14/cmath:3906,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_pair.h:99:12: note: candidates are: 'template<class _Tp, long unsigned int _Nm> struct std::array'
   99 |     struct array;
      |            ^~~~~
a.cc:26:23: note:                 'long long int array [5000]'
   26 | long long int ans, n, array[5000];
      |                       ^~~~~
a.cc: In function 'int main()':
a.cc:22:35: error: no match for 'operator<' (operand types are 'int' and 'std::stack<short int>')
   22 | #define rep(i,n) for(int i = 0; i < x; i++)
      |                                   ^ ~
      |                                     |
      |                                     std::stack<short int>
a.cc:42:9: note: in expansion of macro 'rep'
   42 |         rep(i,n) scanf("%lld", &array[i]);
      |         ^~~
/usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
 1045 |     operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1045:5: note:   template argument deduction/substitution failed:
a.cc:22:37: note:   mismatched types 'const std::pair<_T1, _T2>' and 'int'
   22 | #define rep(i,n) for(int i = 0; i < x; i++)
      |                                     ^
a.cc:42:9: note: in expansion of macro 'rep'
   42 |         rep(i,n) scanf("%lld", &array[i]);
      |         ^~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:67:
/usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
  448 |     operator<(const reverse_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:448:5: note:   template argument deduction/substitution failed:
a.cc:22:37: note:   mismatched types 'const std::reverse_iterator<_Iterator>' and 'int'
   22 | #define rep(i,n) for(int i = 0; i < x; i++)
      |                                     ^
a.cc:42:9: note: in expansion of macro 'rep'
   42 |         rep(i,n) scanf("%lld", &array[i]);
      |         ^~~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
  493 |     operator<(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note:   template argument deduction/substitution failed:
a.cc:22:37: note:   mismatched types 'const std::reverse_iterator<_Iterator>' and 'int'
   22 | #define rep(i,n) for(int i = 0; i < x; i++)
      |                                     ^
a.cc:42:9: note: in expansion of macro 'rep'
   42 |         rep(i,n) scanf("%lld", &array[i]);
      |         ^~~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
 1694 |     operator<(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note:   template argument deduction/substitution failed:
a.cc:22:37: note:   mismatched types 'const std::move_iterator<_IteratorL>' and 'int'
   22 | #define rep(i,n) for(int i = 0; i < x; i++)
      |                                     ^
a.cc:42:9: note: in expansion of macro 'rep'
   42 |         rep(i,n) scanf("%lld", &array[i]);
      |         ^~~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
 1760 |     operator<(const move_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note:   template argument deduction/substitution failed:
a.cc:22:37: note:   mismatched types 'const std::move_iterator<_IteratorL>' and 'int'
   22 | #define rep(i,n) for(int i = 0; i < x; i++)
      |                                     ^
a.cc:42:9: note: in expansion of macro 'rep'
   42 |         rep(i,n) scanf("%lld", &array[i]);
      |         ^~~
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:7:
/usr/include/c++/14/bits/stl_vector.h:2089:5: note: candidate: 'template<class _Tp, class _Alloc> bool std::operator<(const vector<_Tp, _Alloc>&, const vector<_Tp, _Alloc>&)'
 2089 |     operator<(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:2089:5: note:   template argument deduction/substitution failed:
a.cc:22:37: note:   mismatched types 'const std::vector<_Tp, _Alloc>' and 'int'
   22 | #define rep(i,n) for(int i = 0; i < x; i++)
      |                                     ^
a.cc:42:9: note: in expansion of macro 'rep'
   42 |         rep(i,n) scanf("%lld", &array[i]);
      |         ^~~
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
                 from /usr/include/c++/14/vector:87:
/usr/include/c++/14/tuple:2600:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator<(const tuple<_UTypes ...>&, const tuple<_Elements ...>&)'
 2600 |     operator<(const tuple<_TElements...>& __t,
      |     ^~~~~~~~
/usr/include/c++/14/tuple:2600:5: note:   template argument deduction/substitution failed:
a.cc:22:37: note:   mismatched types 'const std::tuple<_UTypes ...>' and 'int'
   22 | #define rep(i,n) for(int i = 0; i < x; i++)
      |                                     ^
a.cc:42:9: note: in expansion of macro 'rep'
   42 |         rep(i,n) scanf("%lld", &array[i]);
      |         ^~~
In file included from /usr/include/c++/14/deque:66,
                 from /usr/include/c++/14/stack:62,
                 from a.cc:9:
/usr/include/c++/14/bits/stl_deque.h:2334:5: note: candidate: 'template<class _Tp, class _Alloc> bool std::operator<(const deque<_Tp, _Alloc>&, const deque<_Tp, _Alloc>&)'
 2334 |     operator<(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y)
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_deque.h:2334:5: note:   template argument deduction/substitution failed:
a.cc:22:37: note:   mismatched types 'const std::deque<_Tp, _Alloc>' and 'int'
   22 | #define rep(i,n) for(int i = 0; i < x; i++)
      |                                     ^
a.cc:42:9: note: in expansion of macro 'rep'
   42 |         rep(i,n) scanf("%lld", &array[i]);
      |         ^~~
In file included from /usr/include/c++/14/stack:63:
/usr/include/c++/14/bits/stl_stack.h:373:5: note: candidate: 'template<class _Tp, class _Seq> bool std::operator<(const stack<_Tp, _Seq>&, const stack<_Tp, _Seq>&)'
  373 |     operator<(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y)
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_stack.h:373:5: note:   template argument deduction/substitution failed:
a.cc:22:37: note:   mismatched types 'const std::stack<_Tp, _Seq>' and 'int'
   22 | #define rep(i,n) for(int i = 0; i < x; i++)
      |                                     ^
a.cc:42:9: note: in expansion of macro 'rep'
   42 |         rep(i,n) scanf("%lld", &array[i]);
      |         ^~~
In file included from /usr/include/c++/14/queue:66,
                 from a.cc:10:
/usr/include/c++/14/bits/stl_queue.h:397:5: note: candidate: 'template<class _Tp, class _Seq> bool std::operator<(const queue<_Tp, _Seq>&, const queue<_Tp, _Seq>&)'
  397 |     operator<(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:397:5: note:   template argument deduction/substitution failed:
a.cc:22:37: note:   mismatched types 'const std::queue<_Tp, _Seq>' and 'int'
   22 | #define rep(i,n) for(int i = 0; i < x; i++)
      |                                     ^
a.cc:42:9: note: in expansion of macro 'rep'
   42 |         rep(i,n) scanf("%lld", &array[i]);
      |         ^~~
In file included from /usr/include/c++/14/list:65,
                 from a.cc:11:
/usr/include/c++/14/bits/stl_list.h:2188:5: note: candidate: 'template<class _Tp, class _Alloc> bool std::operator<(const __cxx11::list<_Tp, _Alloc>&, const __cxx11::list<_Tp, _Alloc>&)'
 2188 |     operator<(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_list.h:2188:5: note:   template argument deduction/substitution failed:
a.cc:22:37: note:   mismatched types 'const std::__cxx11::list<_Tp, _Alloc>' and 'int'
   22 | #define rep(i,n) for(int i = 0; i < x; i++)
      |                                     ^
a.cc:42:9: note: in expansion of macro 'rep'
   42 |         rep(i,n) scanf("%lld", &array[i]);
      |         ^~~
In file included from /usr/include/c++/14/set:63,
                 from a.cc:12:
/usr/include/c++/14/bits/stl_set.h:1025:5: note: candidate: 'template<class _Key, class _Compare, class _Alloc> bool std::operator<(const set<_Key, _Compare, _Allocator>&, const set<_Key, _Compare, _Allocator>&)'
 1025 |     operator<(const set<_Key, _Compare, _Alloc>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_set.h:1025:5: note:   template argument deduction/substitution failed:
a.cc:22:37: note:   mismatched types 'const std::set<_Key, _Compare, _Allocator>' and 'int'
   22 | #define rep(i,n) for(int i = 0; i < x; i++)
      |                                     ^
a.cc:42:9: note: in expansion of macro 'rep'
   42 |         rep(i,n) scanf("%lld", &array[i]);
      |         ^~~
In file included from /usr/include/c++/14/set:64:
/usr/include/c++/14/bits/stl_multiset.h:1011:5: note: candidate: 'template<class _Key, class _Compare, class _Alloc> bool std::operator<(const multiset<_Key, _Compare, _Allocator>&, const