#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  unordered_map<int, int> office;
  set<int> used;
  vector<int> days;
  bool valid = true;
  int cur = 0;
  for (int i = 0; i < n; i++) {
    int emp;
    cin >> emp;
    cur++;
    if (emp < 0) {
      if (office.find(emp * -1) == office.end()) {
        valid = false;
      } else {
        office.erase(emp * -1);
        used.insert(emp * -1);
      }
    } else {
      if (office.find(emp) == office.end()) {
        if (used.find(emp) == used.end()) {
          office[emp] = emp;
        } else {
          valid = false;
        }
      } else {
        valid = false;
      }
    }
    if (office.size() == 0) {
      days.push_back(cur);
      cur = 0;
      used.clear();
    }
  }
  if (office.size() != 0) {
    valid = false;
  }
  if (valid) {
    int l = days.size();
    cout << l << endl;
    for (int i = 0; i < l; i++) {
      cout << days[i] << " ";
    }
  } else {
    cout << -1 << endl;
  }
  return 0;
}
