#include <bits/stdc++.h>
using namespace std;
signed main() {
  int n;
  cin >> n;
  set<int> s, v;
  vector<int> d;
  int x;
  int c = 0;
  int flag = 0;
  for (int i = 0; i < n; i++) {
    cin >> x;
    if (x < 0 && s.find(abs(x)) == s.end())
      flag = 1;
    else if (x < 0) {
      c++;
      s.erase(abs(x));
    } else if (x > 0 && s.find(x) == s.end() && v.find(x) == v.end()) {
      c++;
      s.insert(x);
      v.insert(x);
    } else if (x > 0)
      flag = 1;
    if (s.size() == 0) {
      d.push_back(c);
      c = 0;
      v.clear();
    }
  }
  if (flag == 1 || s.size() != 0)
    cout << "-1" << endl;
  else {
    cout << d.size() << endl;
    for (int i = 0; i < d.size(); i++) cout << d[i] << " ";
    cout << endl;
  }
  return 0;
}
