//#define LOCAL 7
#include<bits/stdc++.h>
using namespace std;
#define wspc "\n\t "
#ifdef LOCAL
#define d(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define d(...) 1729
#endif
void debug() {cerr<<wspc[0];}
template<typename Head,typename... Tail>
void debug(Head H, Tail... T){cerr << " " <<to_string(H);debug(T...);}
template <typename A, typename B>string to_string(pair<A, B> p);
template<typename A,typename B,typename C>string to_string(tuple<A, B, C> p);
template <typename A, typename B, typename C, typename D>string to_string(tuple<A, B, C, D> p);
string to_string(const string& s){return '"'+s+'"';}
string to_string(const char* s){return to_string((string) s);}
string to_string(bool b){return (b?"true":"false");}
string to_string(vector<bool> v){bool first=1;string res="{";for(int i=0;i<static_cast<int>(v.size());i++){
if(!first){res+=", ";}first=0;res+=to_string(v[i]);}res+="}";return res;}
template <size_t N>string to_string(bitset<N> v){string res="";
for(size_t i=0;i<N;i++){res+=static_cast<char>('0'+v[i]);}return res;}
template <typename A>string to_string(A v){bool first=1;string res="{";
for(const auto &x : v){if(!first){res+=", ";}first=0;res+=to_string(x);}res+="}";return res;}
template<typename A,typename B>string to_string(pair<A, B> p)
{return "("+to_string(p.first)+", "+to_string(p.second)+")";}
template<typename A,typename B,typename C>string to_string(tuple<A, B, C> p)
{return"("+to_string(get<0>(p))+", "+to_string(get<1>(p))+", "+to_string(get<2>(p))+")";}
template<typename A,typename B,typename C,typename D>string to_string(tuple<A, B, C, D> p)
{return "("+to_string(get<0>(p))+", "+to_string(get<1>(p))+", "+to_string(get<2>(p))+", "+to_string(get<3>(p))+")";}
#define pb push_back
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fast ios_base::sync_with_stdio(0)
#define scan(a) for(auto &val:a)cin>>val;
//Code started :
const int N = 1e6+5;
char memo[N]={0};
bool solve()
{
int n,tmp;
cin>>n;
int a[n];
scan(a);
vector<int>present,breaks;
int i;
//0->wait,1->entered,2->left
rep(i,n)
{
if(a[i]<0)
{
a[i]=-a[i];
if(memo[a[i]]!=1)
return 0;
memo[a[i]]=2;
}
else if(memo[a[i]]==2)
{
for(auto x : present)
{
if(memo[a[x]]==1)
return 0;
}
//if()
breaks.pb(present.size());
present.clear();
memo[a[i]]=1;
}
else if(memo[a[i]]==0)
memo[a[i]]=1;
else
return 0;
present.pb(i);
tmp=memo[a[i]];
d(i,present);
d(breaks,a[i],tmp);
}
d(present);
for(auto x : present)
{
if(memo[a[x]]==1)
return 0;
}
breaks.pb(present.size());
d(breaks);
cout<<breaks.size()<<'\n';
for(auto x : breaks)
cout<<x<<" ";
return 1;
}
int main()
{
fast;
if(!solve())cout<<"-1\n";
return 0;
}
Ly8jZGVmaW5lIExPQ0FMIDcKI2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCiNkZWZpbmUgd3NwYyAiXG5cdCAiCiNpZmRlZiBMT0NBTAojZGVmaW5lIGQoLi4uKSBjZXJyIDw8ICJbIiA8PCAjX19WQV9BUkdTX18gPDwgIl06IiwgZGVidWcoX19WQV9BUkdTX18pCiNlbHNlCiNkZWZpbmUgZCguLi4pIDE3MjkKI2VuZGlmCnZvaWQgZGVidWcoKSB7Y2Vycjw8d3NwY1swXTt9CnRlbXBsYXRlPHR5cGVuYW1lIEhlYWQsdHlwZW5hbWUuLi4gVGFpbD4Kdm9pZCBkZWJ1ZyhIZWFkIEgsIFRhaWwuLi4gVCl7Y2VyciA8PCAiICIgPDx0b19zdHJpbmcoSCk7ZGVidWcoVC4uLik7fQoKdGVtcGxhdGUgPHR5cGVuYW1lIEEsIHR5cGVuYW1lIEI+c3RyaW5nIHRvX3N0cmluZyhwYWlyPEEsIEI+IHApOwp0ZW1wbGF0ZTx0eXBlbmFtZSBBLHR5cGVuYW1lIEIsdHlwZW5hbWUgQz5zdHJpbmcgdG9fc3RyaW5nKHR1cGxlPEEsIEIsIEM+IHApOwp0ZW1wbGF0ZSA8dHlwZW5hbWUgQSwgdHlwZW5hbWUgQiwgdHlwZW5h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gICAgIGFbaV09LWFbaV07CiAgICAgICAgICAgIGlmKG1lbW9bYVtpXV0hPTEpCiAgICAgICAgICAgICAgICByZXR1cm4gMDsKICAgICAgICAgICAgbWVtb1thW2ldXT0yOwogICAgICAgIH0KICAgICAgICBlbHNlIGlmKG1lbW9bYVtpXV09PTIpCiAgICAgICAgewogICAgICAgICAgICBmb3IoYXV0byB4IDogcHJlc2VudCkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgaWYobWVtb1thW3hdXT09MSkKICAgICAgICAgICAgICAgICAgICByZXR1cm4gMDsKICAgICAgICAgICAgfQogICAgICAgICAgICAvL2lmKCkKICAgICAgICAgICAgYnJlYWtzLnBiKHByZXNlbnQuc2l6ZSgpKTsKICAgICAgICAgICAgcHJlc2VudC5jbGVhcigpOwogICAgICAgICAgICBtZW1vW2FbaV1dPTE7CiAgICAgICAgfQogICAgICAgIGVsc2UgaWYobWVtb1thW2ldXT09MCkKICAgICAgICAgICAgbWVtb1thW2ldXT0xOwogICAgICAgIGVsc2UgCiAgICAgICAgICAgIHJldHVybiAwOwogICAgICAgIAogICAgICAgIHByZXNlbnQucGIoaSk7CiAgICAgICAgdG1wPW1lbW9bYVtpXV07CiAgICAgICAgZChpLHByZXNlbnQpOwogICAgICAgIGQoYnJlYWtzLGFbaV0sdG1wKTsKICAgIH0KCiAgICBkKHByZXNlbnQpOwogICAgZm9yKGF1dG8geCA6IHByZXNlbnQpCiAgICB7CiAgICAgICAgaWYobWVtb1thW3hdXT09MSkKICAgICAgICAgICAgcmV0dXJuIDA7CiAgICB9CiAgICBicmVha3MucGIocHJlc2VudC5zaXplKCkpOwogICAgZChicmVha3MpOwoKICAgIGNvdXQ8PGJyZWFrcy5zaXplKCk8PCdcbic7CiAgICBmb3IoYXV0byB4IDogYnJlYWtzKQogICAgICAgIGNvdXQ8PHg8PCIgIjsKCiAgICByZXR1cm4gMTsKfQoKaW50IG1haW4oKQp7CiAgICBmYXN0OwogICAgaWYoIXNvbHZlKCkpY291dDw8Ii0xXG4iOwogICAgcmV0dXJuIDA7Cn0=