#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int a[1000005];
  memset(a, 0, n + 4);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  unordered_set<int> s, s1;
  vector<int> d;
  int rez = 1, br = 0;
  for (int i = 0; i < n; i++) {
    ++br;
    if (a[i] > 0) {
      if (s.count(a[i]) || s1.count(a[i])) {
        rez = 0;
        break;
      }
      s.insert(a[i]);
      s1.insert(a[i]);
    } else {
      if (!s.count(-a[i])) {
        rez = 0;
        break;
      }
      s.erase(-a[i]);
      if (s.size() == 0) {
        d.push_back(br);
        br = 0;
        s1.clear();
      }
    }
  }
  if (rez == 0 || s.size() != 0 || d.size() == 0)
    cout << -1 << endl;
  else {
    int n1 = (int)d.size();
    cout << n1 << endl;
    for (int i = 0; i < n1; i++) {
      cout << d[i] << " ";
    }
  }
  return 0;
}
