#include <bits/stdc++.h>
using namespace std;
int a[100001];
int main() {
  int n;
  cin >> n;
  set<int> st;
  vector<int> ans;
  bool valid = true;
  unordered_map<int, int> mp;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    mp[a[i]]++;
    if (a[i] > 0 && st.size() != 0 && mp[a[i]] > 1) valid = false;
    if (a[i] > 0)
      st.insert(a[i]);
    else {
      if (st.find(-a[i]) == st.end())
        valid = false;
      else
        st.erase(-a[i]);
    }
    if (st.size() == 0) {
      ans.push_back(i + 1);
      mp.clear();
    }
  }
  if (st.size() != 0 || ans.size() == 0 || valid == false) {
    cout << "-1" << endl;
    return 0;
  }
  cout << ans.size() << endl;
  cout << ans[0] << " ";
  for (int i = 1; i < ans.size(); i++) {
    cout << ans[i] - ans[i - 1] << " ";
  }
  return 0;
}
