#include <bits/stdc++.h>
#pragma optimize("O3")
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;
const int base = 2e5 + 1;
const int MAX = 1e5 + 2;
const double EPS = 1e-9;
const double PI = acos(-1.);
const int MAXN = 1e6 + 47;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {
  int n;
  cin >> n;
  int cnt = 0;
  vector<int> res;
  set<int> was, is;
  for (long long i = (0); i < (n); ++i) {
    int a;
    cin >> a;
    if (a < 0) {
      if (is.count(abs(a))) {
        is.erase(abs(a));
        cnt--;
      } else {
        cout << -1;
        return 0;
      }
    } else {
      if (was.count(a) || is.count(a)) {
        cout << -1;
        return 0;
      } else {
        was.insert(a);
        is.insert(a);
        cnt++;
      }
    }
    if (cnt == 0) {
      res.push_back(i + 1);
      was.clear();
    }
  }
  if (cnt != 0) {
    cout << -1;
    return 0;
  }
  cout << (int)res.size() << '\n';
  int last = 0;
  for (long long i = (0); i < ((int)res.size()); ++i) {
    cout << res[i] - last << ' ';
    last = res[i];
  }
  cerr << "\nTime elapsed: " << clock() / (double)CLOCKS_PER_SEC << '\n';
  return 0;
}
