#include <bits/stdc++.h>
using namespace std;
int in[1000005];
int main() {
  int n;
  scanf("%d", &n);
  vector<int> days;
  int cur = 0;
  set<int> inside;
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    if (x < 0) {
      if (!in[-x]) {
        printf("-1\n");
        return 0;
      }
      in[-x] = false;
      cur--;
    } else {
      if (in[x] || inside.count(x)) {
        printf("-1\n");
        return 0;
      }
      inside.insert(x);
      in[x] = true;
      cur++;
    }
    if (cur == 0) {
      days.push_back(i + 1);
      while (inside.size() > 0) inside.erase(inside.begin());
    }
  }
  if (cur != 0) {
    printf("-1\n");
    return 0;
  }
  printf("%d\n", days.size());
  for (int i = 0; i < days.size(); i++) {
    int x = days[i];
    if (i) x -= days[i - 1];
    printf("%d ", x);
  }
  printf("\n");
}
