Language: C++

#include <iostream>
#include <algorithm>
#include <vector>

int main() {
	int N;
	std::cin >> N;  
  	std::vector<int> data(N-1);
  
  	for(int i = 0; i < N-1; ++i) {
		std::cin >> data[i];
    }

	auto ret = data;
	for(int i = 0; i < data.size()-1; ++i)
		ret[i] = std::count_if(data.begin()+i,data.end(),[](int n, int cn){return n-1==cn;});
  	ret[ret.size()-1] = 0;
  
	for(auto&& e : ret)
      std::cout << e << std::endl;
  
}


Compiler output:
In file included from /usr/include/c++/14/bits/stl_algobase.h:71,
                 from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_pred<_Predicate>::operator()(_Iterator) [with _Iterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; _Predicate = main()::<lambda(int, int)>]':
/usr/include/c++/14/bits/stl_algobase.h:2163:12:   required from 'typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::__count_if(_InputIterator, _InputIterator, _Predicate) [with _InputIterator = __gnu_cxx::__normal_iterator<int*, vector<int> >; _Predicate = __gnu_cxx::__ops::_Iter_pred<main()::<lambda(int, int)> >; typename iterator_traits< <template-parameter-1-1> >::difference_type = long int]'
 2163 |         if (__pred(__first))
      |             ~~~~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4057:29:   required from 'typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::count_if(_IIter, _IIter, _Predicate) [with _IIter = __gnu_cxx::__normal_iterator<int*, vector<int> >; _Predicate = main()::<lambda(int, int)>; typename iterator_traits< <template-parameter-1-1> >::difference_type = long int]'
 4057 |       return std::__count_if(__first, __last,
      |              ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
 4058 |                              __gnu_cxx::__ops::__pred_iter(__pred));
      |                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:16:25:   required from here
   16 |                 ret[i] = std::count_if(data.begin()+i,data.end(),[](int n, int cn){return n-1==cn;});
      |                          ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/predefined_ops.h:318:30: error: no match for call to '(main()::<lambda(int, int)>) (int&)'
  318 |         { return bool(_M_pred(*__it)); }
      |                       ~~~~~~~^~~~~~~
/usr/include/c++/14/bits/predefined_ops.h:318:30: note: candidate: 'bool (*)(int, int)' (conversion)
/usr/include/c++/14/bits/predefined_ops.h:318:30: note:   candidate expects 3 arguments, 2 provided
a.cc:16:66: note: candidate: 'main()::<lambda(int, int)>'
   16 |                 ret[i] = std::count_if(data.begin()+i,data.end(),[](int n, int cn){return n-1==cn;});
      |                                                                  ^
a.cc:16:66: note:   candidate expects 2 arguments, 1 provided