#include <bits/stdc++.h>
using namespace std;
inline long long add(long long a, long long b) {
  return ((a % 1000000007) + (b % 1000000007)) % 1000000007;
}
inline long long mul(long long a, long long b) {
  return ((a % 1000000007) * (b % 1000000007)) % 1000000007;
}
inline long long sub(long long a, long long b) {
  return ((a % 1000000007) - (b % 1000000007) + 1000000007) % 1000000007;
}
void c_p_c() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int32_t main() {
  c_p_c();
  long long n;
  cin >> n;
  long long arr[n];
  for (long long i = 0; i < n; i++) cin >> arr[i];
  map<long long, long long> mpp;
  bool ok = true;
  vector<long long> soln;
  long long curSize = 0;
  set<long long> st;
  for (long long i = 0; i < n; i++) {
    if (arr[i] > 0) {
      if (mpp.find(arr[i]) != mpp.end()) {
        ok = false;
        break;
      }
      if (st.count(arr[i])) {
        ok = false;
        break;
      }
      mpp[arr[i]] = 1;
      curSize++;
    } else {
      if (mpp.find(-arr[i]) != mpp.end()) {
        mpp.erase(-arr[i]);
        st.insert(-arr[i]);
      } else {
        ok = false;
        break;
      }
      if (mpp.size() == 0) {
        st.clear();
        soln.push_back(curSize * 2);
        curSize = 0;
      }
    }
  }
  if (!ok || mpp.size() > 0) {
    cout << -1;
    return 0;
  }
  cout << soln.size() << endl;
  for (long long i = 0; i < soln.size(); i++) cout << soln[i] << " ";
}
