Language: C++

#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long
#define pii pair<int,int>
#define pll pair<LL,LL>

using namespace std;

int main(){
    int N;cin>>N;
    LL a[N+1];REP(i,N)cin>>a[i+1];
    a[0]=0;

    for(int i=N;i>0;--i){
        LL ret = 0;
        for(int j=i;j<=N;j+=i)ret+=a[j];
        if(ret<0)for(int j=i;j<=N;j+=i)a[j]=0;
    }

    LL ans = accumulate(a,a+N+1);
    while(true){
        for(int i=N;i>0;--i){
            LL ret = 0;
            for(int j=i;j<=N;j+=i)ret+=a[j];
            if(ret<0)for(int j=i;j<=N;j+=i)a[j]=0;
        }
        if(ans == accumulate(a,a+N+1))break;
        ans = accumulate(ALL(a));
    }



    cout<<ans<<endl;


    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:24: error: no matching function for call to 'accumulate(long long int [(N + 1)], long long int*)'
   21 |     LL ans = accumulate(a,a+N+1);
      |              ~~~~~~~~~~^~~~~~~~~
In file included from /usr/include/c++/14/numeric:62,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:58,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_numeric.h:134:5: note: candidate: 'template<class _InputIterator, class _Tp> _Tp std::accumulate(_InputIterator, _InputIterator, _Tp)'
  134 |     accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
      |     ^~~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:134:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_numeric.h:161:5: note: candidate: 'template<class _InputIterator, class _Tp, class _BinaryOperation> _Tp std::accumulate(_InputIterator, _InputIterator, _Tp, _BinaryOperation)'
  161 |     accumulate(_InputIterator __first, _InputIterator __last, _Tp __init,
      |     ^~~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:161:5: note:   candidate expects 4 arguments, 2 provided
a.cc:28:29: error: no matching function for call to 'accumulate(long long int [(N + 1)], long long int*)'
   28 |         if(ans == accumulate(a,a+N+1))break;
      |                   ~~~~~~~~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:134:5: note: candidate: 'template<class _InputIterator, class _Tp> _Tp std::accumulate(_InputIterator, _InputIterator, _Tp)'
  134 |     accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
      |     ^~~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:134:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_numeric.h:161:5: note: candidate: 'template<class _InputIterator, class _Tp, class _BinaryOperation> _Tp std::accumulate(_InputIterator, _InputIterator, _Tp, _BinaryOperation)'
  161 |     accumulate(_InputIterator __first, _InputIterator __last, _Tp __init,
      |     ^~~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:161:5: note:   candidate expects 4 arguments, 2 provided
a.cc:3:20: error: request for member 'begin' in 'a', which is of non-class type 'long long int [(N + 1)]'
    3 | #define ALL(x) (x).begin(),(x).end()
      |                    ^~~~~
a.cc:29:26: note: in expansion of macro 'ALL'
   29 |         ans = accumulate(ALL(a));
      |                          ^~~
a.cc:3:32: error: request for member 'end' in 'a', which is of non-class type 'long long int [(N + 1)]'
    3 | #define ALL(x) (x).begin(),(x).end()
      |                                ^~~
a.cc:29:26: note: in expansion of macro 'ALL'
   29 |         ans = accumulate(ALL(a));
      |                          ^~~