Language: C++

#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 2e5 + 5, M = 1e5 + 5;

ll lcm(1);
bool here;

ll getLcm(ll x, ll y){
    here = 1;
    return (x / __gcd(x, y)) * y;
}

int a[N], me[N];

int main(){
    int n;
    scanf("%d", &n);
    for(int i = 0 ; i < n ; ++i){
        scanf("%d", a + i);
        if(a[i] == 1)
            lcm = getLcm(lcm, i + 1);
    }
    if(n == 1){
        if(a[i] == 0)
            return printf("0"), 0;
        return printf("-1"), 0;
    }
    if(lcm > 1LL * n)return printf("-1\n"), 0;
    if(lcm == 1){
        if(here == 0)
            return printf("0"), 0;
        if(n & 1)
            return printf("1\n1\n"), 0;
        return printf("-1"), 0;
    }
    for(int i = 1 ; i <= n ; ++i){
        if(lcm % i)continue;
        if(a[i - 1] == 0)return printf("-1\n"), 0;
    }
    printf("1\n%lld\n", lcm);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:13: error: reference to 'lcm' is ambiguous
   25 |             lcm = getLcm(lcm, i + 1);
      |             ^~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:58,
                 from a.cc:2:
/usr/include/c++/14/numeric:188:5: note: candidates are: 'template<class _Mn, class _Nn> constexpr std::common_type_t<_Mn, _Nn> std::lcm(_Mn, _Nn)'
  188 |     lcm(_Mn __m, _Nn __n) noexcept
      |     ^~~
a.cc:9:4: note:                 'long long int lcm'
    9 | ll lcm(1);
      |    ^~~
a.cc:25:26: error: reference to 'lcm' is ambiguous
   25 |             lcm = getLcm(lcm, i + 1);
      |                          ^~~
/usr/include/c++/14/numeric:188:5: note: candidates are: 'template<class _Mn, class _Nn> constexpr std::common_type_t<_Mn, _Nn> std::lcm(_Mn, _Nn)'
  188 |     lcm(_Mn __m, _Nn __n) noexcept
      |     ^~~
a.cc:9:4: note:                 'long long int lcm'
    9 | ll lcm(1);
      |    ^~~
a.cc:28:14: error: 'i' was not declared in this scope
   28 |         if(a[i] == 0)
      |              ^
a.cc:32:8: error: reference to 'lcm' is ambiguous
   32 |     if(lcm > 1LL * n)return printf("-1\n"), 0;
      |        ^~~
/usr/include/c++/14/numeric:188:5: note: candidates are: 'template<class _Mn, class _Nn> constexpr std::common_type_t<_Mn, _Nn> std::lcm(_Mn, _Nn)'
  188 |     lcm(_Mn __m, _Nn __n) noexcept
      |     ^~~
a.cc:9:4: note:                 'long long int lcm'
    9 | ll lcm(1);
      |    ^~~
a.cc:33:8: error: reference to 'lcm' is ambiguous
   33 |     if(lcm == 1){
      |        ^~~
/usr/include/c++/14/numeric:188:5: note: candidates are: 'template<class _Mn, class _Nn> constexpr std::common_type_t<_Mn, _Nn> std::lcm(_Mn, _Nn)'
  188 |     lcm(_Mn __m, _Nn __n) noexcept
      |     ^~~
a.cc:9:4: note:                 'long long int lcm'
    9 | ll lcm(1);
      |    ^~~
a.cc:41:12: error: reference to 'lcm' is ambiguous
   41 |         if(lcm % i)continue;
      |            ^~~
/usr/include/c++/14/numeric:188:5: note: candidates are: 'template<class _Mn, class _Nn> constexpr std::common_type_t<_Mn, _Nn> std::lcm(_Mn, _Nn)'
  188 |     lcm(_Mn __m, _Nn __n) noexcept
      |     ^~~
a.cc:9:4: note:                 'long long int lcm'
    9 | ll lcm(1);
      |    ^~~
a.cc:44:25: error: reference to 'lcm' is ambiguous
   44 |     printf("1\n%lld\n", lcm);
      |                         ^~~
/usr/include/c++/14/numeric:188:5: note: candidates are: 'template<class _Mn, class _Nn> constexpr std::common_type_t<_Mn, _Nn> std::lcm(_Mn, _Nn)'
  188 |     lcm(_Mn __m, _Nn __n) noexcept
      |     ^~~
a.cc:9:4: note:                 'long long int lcm'
    9 | ll lcm(1);
      |    ^~~