#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int n, i, j;
  cin >> n;
  long long int a[n], cnt = 0, l = 0, r = 0;
  map<long long int, long long int> m;
  vector<long long int> day;
  set<long long int> s;
  for (i = 0; i < n; i++) cin >> a[i];
  for (i = 0; i < n; i++) {
    if (a[i] > 0 && s.find(a[i]) != s.end()) {
      cout << "-1";
      return;
    }
    if (a[i] > 0) {
      cnt++;
      m[a[i]]++;
      r++;
    } else {
      if (m[abs(a[i])] != 1) {
        cout << "-1";
        return;
      } else {
        m[abs(a[i])]--;
        cnt--;
        s.insert(abs(a[i]));
        if (cnt == 0) {
          r++;
          day.push_back(r - l);
          l = r;
          s.clear();
        } else
          r++;
      }
    }
  }
  if (cnt != 0)
    cout << "-1";
  else {
    cout << day.size() << endl;
    for (i = 0; i < day.size(); i++) cout << day[i] << " ";
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t;
  t = 1;
  while (t--) solve();
  cerr << "\nTime elapsed: " << setprecision(5)
       << 1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}
