#include <bits/stdc++.h>
unsigned workerlog[1000000], entered[50000];
void clr(unsigned *arr) {
  int i;
  while (*(arr + i) != 0) {
    *(arr + i) = 0;
    i++;
  }
}
int isentered(int a) {
  int i = 0;
  while (entered[i] != 0) {
    if (entered[i] == a) return 1;
    i++;
  }
  return 0;
}
int main() {
  long double sum = 0;
  int n, i, day = 0, pos = 0;
  scanf("%d", &n);
  int a[n], div[n];
  for (i = 0; i < n; i++) {
    a[i] = 0;
    div[i] = 0;
  }
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    sum += a[i];
  }
  if (n % 2 != 0) {
    printf("-1");
    return 0;
  }
  if (sum != 0) {
    printf("-1");
    return 0;
  }
  for (i = 0; i < n; i++) {
    sum += a[i];
    if (a[i] > 0) {
      if ((workerlog[a[i] - 1] % 2 != 0) ||
          (workerlog[a[i] - 1] >= day * 2 + 2) || isentered(a[i])) {
        printf("-1");
        return 0;
      }
      workerlog[a[i] - 1]++;
      entered[pos++] = a[i];
    } else {
      if (workerlog[abs(a[i]) - 1] % 2 != 1) {
        printf("-1");
        return 0;
      }
      workerlog[abs(a[i]) - 1]++;
    }
    if (sum < 0) {
      printf("-1");
      return 0;
    } else if (sum == 0) {
      div[++day] = i;
      clr(entered);
      pos = 0;
    }
  }
  printf("%d\n", day);
  for (i = 1; i <= day; i++) {
    if (i == 1)
      printf("%d ", div[i] - div[i - 1] + 1);
    else
      printf("%d ", div[i] - div[i - 1]);
  }
  return 0;
}
