#include <bits/stdc++.h>
using namespace std;
const int N = 1e7 + 10;
map<int, bool> vis;
set<int> b;
int n, a[N], c[N];
set<int>::iterator it;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (vis[a[i]]) {
      printf("-1\n");
      return 0;
    }
    vis[a[i]] = true;
    if (a[i] > 0) {
      b.insert(a[i]);
    } else {
      it = b.find(-a[i]);
      if (it == b.end()) {
        printf("-1\n");
        return 0;
      }
      b.erase(it);
    }
    if (b.size() == 0 && vis.size()) {
      c[ans++] = vis.size();
      vis.clear();
    }
  }
  if (b.size()) {
    printf("-1\n");
    return 0;
  }
  if (ans == 0) {
    printf("1\n%d\n", n);
  } else {
    printf("%d\n", ans);
    for (int i = 0; i < ans; i++) {
      printf("%d ", c[i]);
    }
  }
  return 0;
}
