#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long a[n];
  unordered_set<long long> st;
  unordered_map<long long, long long> mp;
  vector<long long> V;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] < 0) {
      if (st.find(abs(a[i])) == st.end()) {
        cout << -1 << "\n";
        return 0;
      } else {
        if (mp.find(abs(a[i])) == mp.end()) {
          cout << -1 << "\n";
          return 0;
        }
        mp.erase(abs(a[i]));
        if (mp.size() == 0) {
          V.push_back(i);
          st.clear();
          mp.clear();
        }
      }
    } else {
      if (a[i] > 0 && st.find(a[i]) == st.end()) {
        st.insert(a[i]);
        mp[a[i]]++;
      } else {
        if (mp.size() != 0 && st.size() != 0) {
          cout << -1 << "\n";
          return 0;
        }
        if (st.size() == 0 && mp.size() == 0) {
          st.insert(a[i]);
          mp[a[i]]++;
        } else {
          cout << -1 << "\n";
          break;
        }
      }
    }
  }
  if (st.size() == 0 && mp.size() == 0) {
    long long sz = V.size();
    cout << sz << "\n";
    cout << V[0] + 1 << " ";
    for (long long i = 1; i < sz; i++) cout << V[i] - V[i - 1] << " ";
    cout << "\n";
  } else
    cout << -1 << "\n";
  return 0;
}
