#include <bits/stdc++.h>
template <class T>
inline bool cmax(T& a, const T& b) {
  return a < b ? a = b, 1 : 0;
}
template <class T>
inline bool cmin(T& a, const T& b) {
  return a > b ? a = b, 1 : 0;
}
namespace IO {
char ss[1 << 17], *A = ss, *B = ss;
inline char gc() {
  return A == B && (B = (A = ss) + fread(ss, 1, 1 << 17, stdin), A == B) ? -1
                                                                         : *A++;
}
template <class T>
inline void In(T& x) {
  char c;
  T y = 1;
  while (c = gc(), (c < 48 || 57 < c) && c != -1)
    if (c == 45) {
      y = -1;
    }
  x = c - 48;
  while (c = gc(), 47 < c && c < 58) {
    x = x * 10 + c - 48;
  }
  x *= y;
}
char sr[1 << 21], z[20];
int C = -1, Z;
inline void Write() { fwrite(sr, 1, C + 1, stdout), C = -1; }
template <class T>
inline void Out(T x, char c = ' ') {
  if (C > 1 << 20) {
    Write();
  }
  if (x < 0) {
    sr[++C] = 45, x = -x;
  }
  while (z[++Z] = x % 10 + 48, x /= 10)
    ;
  while (sr[++C] = z[Z], --Z) {
  };
  sr[++C] = c;
}
}  // namespace IO
using namespace std;
using namespace IO;
const int N = 1e6 + 5, Inf = -1u >> 1;
using ll = long long;
using arr = int[N];
int n, Cnt;
arr vis, Bel;
vector<int> Ans;
int main() {
  In(n);
  int x, d = 0;
  memset(Bel, -1, sizeof Bel);
  for (register int i = 1, I = n + 1; i < I; ++i) {
    In(x);
    ++d;
    if (x < 0) {
      if (!vis[-x]) puts("-1"), exit(0);
      vis[-x] = 0;
      --Cnt;
      if (!Cnt) Ans.push_back(d), d = 0;
    } else {
      if (Bel[x] == (int)Ans.size()) puts("-1"), exit(0);
      vis[x] = 1;
      ++Cnt;
      Bel[x] = Ans.size();
    }
  }
  if (Cnt) puts("-1"), exit(0);
  Out(Ans.size(), '\n');
  for (auto i : Ans) Out(i);
  return Write(), 0;
}
