#include <bits/stdc++.h>
using namespace std;
long long mod(long long n) {
  return (n % (long long)1000000007 + (long long)1000000007) %
         (long long)1000000007;
}
int main() {
  long long n;
  cin >> n;
  vector<long long> ans;
  long long prev = -1;
  multiset<long long> s;
  vector<long long> a(n);
  for (long long i = 0; i < n; i = i + 1) {
    long long x;
    cin >> x;
    a[i] = x;
    if (x > 0)
      s.insert(x);
    else {
      auto itr = s.find(-1 * x);
      if (itr == s.end()) {
        return cout << -1, 0;
      } else {
        s.erase(s.find(-1 * x));
      }
      if (s.empty()) {
        ans.push_back(i - prev), prev = i;
      }
    }
  }
  if (!s.empty()) return cout << -1, 0;
  long long sz = ans.size();
  long long st = 0;
  long long last = 0;
  vector<long long> cnt(1000000, 0);
  for (long long i = 0; i < sz; i = i + 1) {
    last += ans[i];
    for (long long j = st; j < last; j = j + 1) {
      if (a[j] > 0) cnt[a[j]]++;
      if (a[j] > 0 && cnt[a[j]] >= 2) {
        return cout << -1, 0;
      }
    }
    for (long long j = st; j < last; j = j + 1) {
      if (a[j] > 0) cnt[a[j]] = 0;
    }
    st = last;
  }
  cout << sz << endl;
  for (auto val : ans) {
    cout << val << " ";
  }
  cout << endl;
}
