#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v(n), presum(n), events;
  for (int i = 0; i < n; i++) cin >> v[i], presum[i] = v[i];
  for (int i = 1; i < n; i++) presum[i] += presum[i - 1];
  int days = 0, i = 0, prev;
  if (n == 1 && n % 2 == 1)
    cout << -1;
  else {
    set<int> in, out;
    bool flag = true;
    int p = 0;
    while (i < n) {
      if (v[i] > 0) {
        prev = in.size();
        in.insert(v[i]);
        if (in.size() == prev) flag = false;
      } else {
        prev = out.size();
        out.insert(v[i]);
        if (out.size() == prev) flag = false;
        prev = in.size();
        in.insert(-v[i]);
        if (prev != in.size()) flag = false;
      }
      p++;
      if (presum[i] == 0) {
        days++;
        events.push_back(p);
        p = 0;
        in.clear();
        out.clear();
      }
      i++;
    }
    if (!flag || presum[n - 1] != 0)
      cout << -1;
    else {
      cout << days << endl;
      for (int j = 0; j < events.size(); j++) {
        cout << events[j] << " ";
      }
    }
  }
  return 0;
}
