#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  long long a[n];
  for (long long i = 0; i < n; ++i) cin >> a[i];
  if (a[0] < 0) {
    cout << -1 << '\n';
  } else {
    set<long long> s, e;
    long long k = 0;
    s.insert(a[0]);
    e.insert(a[0]);
    vector<long long> v;
    long long ans = 1;
    for (long long i = 1; i < n; ++i) {
      if (s.size() == 0) {
        k++;
        v.push_back(ans);
        ans = 0;
        s.clear();
        e.clear();
      }
      if (a[i] > 0) {
        if (e.find(a[i]) == e.end()) {
          e.insert(a[i]);
          s.insert(a[i]);
          ans++;
        } else {
          cout << -1 << '\n';
          return 0;
        }
      } else {
        if (s.find(-a[i]) != s.end()) {
          s.erase(-a[i]);
          ans++;
        } else {
          cout << -1 << '\n';
          return 0;
        }
      }
    }
    if (s.size() == 0) {
      k++;
      v.push_back(ans);
    } else {
      cout << -1 << '\n';
      return 0;
    }
    cout << k << '\n';
    for (long long i = 0; i < k; ++i) cout << v[i] << " ";
  }
}
