#include <bits/stdc++.h>
using namespace std;
int book[1000100];
int day[1000100];
int que[1000100];
int main() {
  int n, i;
  cin >> n;
  int people = 0;
  int sum = 0;
  int a;
  int flag = 1;
  int all = 0, count = 1;
  int begin = 1, end = 1;
  int j;
  for (i = 1; i <= n; i++) {
    cin >> a;
    if (a > 0) {
      if (book[a] == 0) {
        book[a] = 1;
        people++;
        all++;
        que[end++] = a;
      } else
        flag = 0;
    }
    if (a < 0) {
      if (book[-a] == 1) {
        all++;
        people--;
        book[-a] = 2;
        if (people == 0) {
          day[count++] = all;
          all = 0;
          for (j = begin; j < end; j++) {
            book[que[j]] = 0;
          }
          begin = end;
        }
      } else
        flag = 0;
    }
  }
  if (flag && n % 2 == 0 && all == 0) {
    cout << count - 1 << endl;
    for (i = 1; i < count; i++) {
      cout << day[i] << " ";
    }
  } else
    cout << "-1";
}
