#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long k, p = 1;
  long long n, m, tmp;
  string s[200000];
  string str;
  long long sum = 0;
  long long strr[200005];
  int dayss[1000000];
  cin >> n;
  vector<int> a(n);
  queue<int> q;
  for (long long i = (long long)(0); i < (long long)(n); i++) cin >> a[i];
  set<int> set, dset;
  int days = 0;
  int f = 0;
  int j = 0;
  int r = 0;
  for (long long i = (long long)(0); i < (long long)(n); i++) {
    if (a[i] < 0) {
      auto itr = set.find(abs(a[i]));
      dset.insert(abs(a[i]));
      if (itr == set.end()) {
        cout << -1 << endl;
        return 0;
      }
      set.erase(itr);
    } else {
      if (set.find(a[i]) != set.end()) f = 1;
      set.insert(a[i]);
      if (dset.find(a[i]) != dset.end()) f = 1;
    }
    if (set.empty()) {
      days++;
      q.push(i + 1 - r);
      j++;
      r = i + 1;
      dset.clear();
    }
  }
  if (!set.empty()) f = 1;
  if (f == 1 || n % 2) {
    cout << -1 << endl;
  } else {
    cout << days << endl;
    while (!q.empty()) {
      cout << q.front() << " ";
      q.pop();
    }
    cout << '\n';
  }
  return 0;
}
