#include <bits/stdc++.h>
using namespace std;
long long n, x, mx;
set<long long> s;
map<long long, long long> mp;
vector<int> v;
long long sum;
int main() {
  cin >> n;
  long long a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  if (n & 1) return cout << "-1" << endl, 0;
  mp.clear();
  for (int i = 0; i < n; i++) {
    if (a[i] > 0) {
      if (mp[a[i]]) return cout << "-1" << endl, 0;
      mp[a[i]]++;
      s.insert(a[i]);
      sum++;
    } else {
      if (!mp[-a[i]] || mp[-a[i]] > 1) return cout << "-1" << endl, 0;
      s.erase(-a[i]);
      sum++;
      set<long long>::iterator itr = s.begin();
      if (s.empty()) {
        v.push_back(sum);
        sum = 0;
        mp.clear();
      }
    }
  }
  if (!s.empty()) return cout << "-1" << endl, 0;
  cout << v.size() << endl;
  for (int i = 0; i < v.size(); i++) cout << v[i] << " ";
  cout << endl;
}
