#include <bits/stdc++.h>
using namespace std;
int q = 1;
const int N = 100100;
int n, a[N], ans;
vector<int> v;
map<int, int> mp;
set<int> s;
int t;
void solve() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] > 0) {
      if (s.find(a[i]) == s.end()) {
        s.insert(a[i]);
      } else {
        cout << -1;
        return;
      }
      mp[a[i]] = 1;
      t++;
    } else {
      if (mp[-a[i]]) {
        mp.erase(-a[i]);
        t++;
      } else {
        cout << -1;
        return;
      }
    }
    if (mp.empty()) {
      ans++;
      v.push_back(t);
      s.clear();
      t = 0;
    }
  }
  if (!mp.empty()) {
    cout << -1;
    return;
  }
  cout << ans << endl;
  for (auto x : v) {
    cout << x << " ";
  }
}
int main() {
  std::ios_base::sync_with_stdio(false);
  while (q--) {
    solve();
  }
}
