#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long n;
  cin >> n;
  long long d = 0;
  vector<long long> v;
  vector<long long> a;
  long long val = 0;
  map<long long, long long> m;
  long long start = 0, end = -1, count = 0;
  for (long long i = 0; i < (long long)n; i++) {
    cin >> val;
    if (i == 0) {
      if (val < 0) {
        count++;
        break;
      } else {
        v.push_back(val);
        m[val]++;
      }
    } else {
      if (val > 0) {
        if (m[val] >= m[-val] && m[val] == 0) {
          v.push_back(val);
          m[val]++;
        } else {
          count++;
          break;
        }
      } else {
        if (v.size() == 0 && start != end) {
          d++;
          end = i;
          a.push_back(end - start + 1);
          start = i + 1;
          m.clear();
        }
        if (m[val] >= m[-val]) {
          count++;
          break;
        } else {
          m[val]++;
          for (long long j = 0; j < v.size(); j++) {
            if (v[j] == (-val)) {
              v.erase(v.begin() + j);
              break;
            }
          }
        }
        if (v.size() == 0 && start != end) {
          d++;
          end = i;
          a.push_back(end - start + 1);
          start = i + 1;
          m.clear();
        }
      }
    }
  }
  if (v.size() != 0 || count > 0) {
    cout << -1 << "\n";
  } else {
    cout << d << "\n";
    for (long long i = 0; i < a.size(); i++) {
      cout << a[i] << " ";
    }
    cout << "\n";
  }
  return 0;
}
