#include <bits/stdc++.h>
using namespace std;
int n;
int a[100010];
int isIn[1000010];
int inCount;
std::vector<int> ans;
std::vector<int> inNums;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &(a[i]));
    if (a[i] > 0) isIn[a[i]] = 0;
  }
  inCount = 0;
  bool inEnd = true;
  int p = 0;
  int total = 0;
  while (p < n) {
    if (a[p] > 0) {
      if (isIn[a[p]] == 0) {
        isIn[a[p]] = 1;
        inCount++;
      } else {
        printf("-1\n");
        return 0;
      }
    } else {
      int num = -a[p];
      if (isIn[num] == 1) {
        isIn[num] = -1;
        inCount--;
        inNums.push_back(num);
      } else {
        printf("-1\n");
        return 0;
      }
    }
    total++;
    if (inCount == 0) {
      ans.push_back(total);
      total = 0;
      for (int i = 0; i < inNums.size(); i++) isIn[inNums[i]] = 0;
      inNums.clear();
    }
    p++;
  }
  if (inCount != 0) {
    printf("-1\n");
    return 0;
  }
  printf("%d\n", ans.size());
  printf("%d", ans[0]);
  for (int i = 1; i < ans.size(); i++) printf(" %d", ans[i]);
  printf("\n");
  return 0;
}
