#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int MX = 2e5 + 5;
const long long INF = 1e18;
const long double PI = 4 * atan((long double)1);
template <class T>
bool ckmin(T& a, const T& b) {
  return a > b ? a = b, 1 : 0;
}
template <class T>
bool ckmax(T& a, const T& b) {
  return a < b ? a = b, 1 : 0;
}
long long a[200005];
int main() {
  long long num, num1, sum = 0, test, cnt = 0, num2, num3, ans = 0;
  cin >> num;
  vector<long long> v, vv;
  int j = 1;
  for (int i = 0; i < num; i++) {
    cin >> num1;
    v.push_back(num1);
  }
  long long in = 0, out = 0;
  map<long long, long long> make_pair, mp1;
  stack<long long> st;
  for (int i = 0; i < num; i++) {
    if (v[i] < 0 && make_pair[-1 * v[i]] == 0) {
      cout << -1 << endl;
      return 0;
    }
    if (v[i] < 0) {
      in--;
      mp1[-1 * v[i]]++;
      if (mp1[-1 * v[i]] > 1) {
        cout << -1 << endl;
        return 0;
      }
    } else if (v[i] > 0) {
      in++;
      make_pair[v[i]]++;
      st.push(v[i]);
    }
    if (v[i] > 0 && make_pair[v[i]] > 1) {
      cout << -1 << endl;
      return 0;
    }
    if (in == 0) {
      int ok = 0;
      while (!st.empty()) {
        num2 = st.top();
        if (make_pair[num2] != mp1[num2]) {
          ok = 1;
        }
        st.pop();
      }
      if (ok == 0) {
        ans = i + 1 - cnt;
        vv.push_back(ans);
        cnt = cnt + ans;
        make_pair.clear();
        mp1.clear();
      } else {
        cout << -1 << endl;
        return 0;
      }
    } else if (in < 0) {
      cout << -1 << endl;
      return 0;
    }
  }
  if (in > 0 || in < 0) {
    cout << -1 << endl;
    return 0;
  }
  cout << vv.size() << endl;
  for (int i = 0; i < vv.size(); i++) {
    cout << vv[i] << " ";
  }
  cout << endl;
}
