#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long t;
  t = 1;
  while (t--) {
    long long n;
    cin >> n;
    vector<long long> a(n);
    for (long long i = 0; i < n; i++) {
      cin >> a[i];
    }
    vector<long long> res;
    unordered_map<long long, long long> u;
    long long count = 0;
    long long flag = 0;
    long long prev = 0;
    for (long long i = 0; i < n; i++) {
      if (a[i] > 0) {
        if (!u.count(a[i])) {
          u[a[i]] = 2;
          count++;
        } else {
          flag = 1;
          break;
        }
      } else if (a[i] < 0) {
        if (u.count(-a[i]) && u[-a[i]] == 2) {
          u[-a[i]] = 1;
          count--;
        } else {
          flag = 1;
          break;
        }
      }
      if (count == 0) {
        u.clear();
        res.push_back(i + 1 - prev);
        prev = i + 1;
      }
    }
    if (flag == 1 || u.size()) {
      cout << -1 << endl;
    } else {
      cout << res.size() << endl;
      for (long long i = 0; i < res.size(); i++) {
        cout << res[i] << " ";
      }
      cout << endl;
    }
  }
  return 0;
}
