#include <bits/stdc++.h>
using namespace std;
int i, t, j;
int n, nt, a[100005], total, cnt, ans[100005];
bool ok;
map<int, int> enter, leave;
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
  }
  ok = 1;
  cnt = 1;
  total = 0;
  for (i = 1; i <= n; ++i) {
    if (a[i] < 0) {
      a[i] = -a[i];
      if (enter[a[i]] - leave[a[i]] != 1) {
        ok = 0;
        break;
      } else {
        ++ans[cnt];
        ++leave[a[i]];
        if (leave[a[i]] > enter[a[i]]) {
          ok = 0;
          break;
        }
        --total;
        if (total == 0) {
          ++cnt;
          enter.clear();
          leave.clear();
        }
      }
    } else {
      if (enter[a[i]] != leave[a[i]]) {
        ok = 0;
        break;
      } else {
        ++ans[cnt];
        ++enter[a[i]];
        if (enter[a[i]] >= 2) {
          ok = 0;
          break;
        }
        ++total;
      }
    }
  }
  if (total != 0) ok = 0;
  if (ok == 0)
    printf("-1\n");
  else {
    if (ans[cnt] == 0) --cnt;
    printf("%d\n", cnt);
    for (i = 1; i <= cnt; ++i) printf("%d%c", ans[i], i == cnt ? '\n' : ' ');
  }
  return 0;
}
