#include <bits/stdc++.h>
using namespace std;
const long double pi = acos(-1);
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
  for (auto& i : v) is >> i;
  return is;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
  for (auto& i : v) os << i << ' ';
  return os;
}
void slv() {
  int n;
  cin >> n;
  set<int> st;
  vector<int> ans;
  int sum = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (x > 0) {
      if (st.count(x)) {
        cout << -1 << '\n';
        return;
      }
      st.insert(x);
      sum++;
    } else {
      if (!st.count(-x) || st.count(x)) {
        cout << -1 << '\n';
        return;
      }
      st.insert(x);
      sum--;
    }
    if (sum == 0) {
      ans.push_back(st.size());
      st.clear();
    }
  }
  if (st.empty()) {
    cout << ans.size() << '\n';
    for (auto it : ans) cout << it << ' ';
    cout << '\n';
  } else
    cout << -1 << '\n';
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int tc = 1;
  while (tc--) {
    slv();
  }
  return 0;
}
