#include <bits/stdc++.h>
using namespace std;
int min(int a, int b) {
  if (a < b) return a;
  return b;
}
int main() {
  int n;
  cin >> n;
  vector<int> a;
  int y;
  for (int i = 0; i < n; i++) {
    cin >> y;
    a.push_back(y);
  }
  int d = 0;
  vector<int> c;
  c.push_back(0);
  unordered_set<int> office, entry;
  for (int i = 0; i < n; i++) {
    int cur = a[i];
    if (a[i] > 0) {
      if (office.find(cur) != office.end()) {
        cout << "-1" << endl;
        return 0;
      }
      if (entry.find(cur) != entry.end()) {
        if (office.size() != 0) {
          cout << "-1" << endl;
          return 0;
        }
        d++;
        c.push_back(1);
        entry.clear();
        entry.insert(cur);
        office.insert(cur);
        continue;
      }
      c[d]++;
      entry.insert(cur);
      office.insert(cur);
    } else {
      cur = -cur;
      if (office.find(cur) == office.end()) {
        cout << "-1" << endl;
        return 0;
      }
      office.erase(cur);
      c[d]++;
    }
    if (office.size() == 0 && i < n - 1) {
      entry.clear();
      d++;
      c.push_back(0);
    }
  }
  if (office.size() != 0) {
    cout << "-1" << endl;
    return 0;
  }
  cout << d + 1 << endl;
  for (int i = 0; i <= d; i++) cout << c[i] << " ";
  cout << endl;
  return 0;
}
