#include <bits/stdc++.h>
using namespace std;
int v[100010], sol[100010], f[1000010], day[1000010];
int main() {
  FILE *fin = stdin;
  FILE *fout = stdout;
  int n, ans, oameni, elem, i;
  fscanf(fin, "%d", &n);
  for (i = 1; i <= n; i++) {
    fscanf(fin, "%d", &v[i]);
  }
  ans = 0;
  oameni = 0;
  elem = 0;
  for (i = 1; i <= n; i++) {
    if (v[i] > 0) {
      if (!f[v[i]]) {
        if (day[v[i]] == elem + 1) ans = 1;
        f[v[i]] = 1;
        oameni++;
        day[v[i]] = elem + 1;
      } else
        ans = 1;
    } else {
      if (!f[-v[i]]) {
        ans = 1;
      } else {
        f[-v[i]] = 0;
        oameni--;
      }
    }
    if (!oameni) {
      elem++;
      sol[elem] = i;
    }
  }
  if (sol[elem] != n) ans = 1;
  if (ans == 1)
    fprintf(fout, "-1");
  else {
    fprintf(fout, "%d\n", elem);
    for (i = 1; i <= elem; i++) fprintf(fout, "%d ", sol[i] - sol[i - 1]);
  }
  return 0;
}
