#include <bits/stdc++.h>
using namespace std;
void printv(vector<long long> v) {
  for (long long i = 0; i < v.size(); i++) cout << v[i] << ' ';
  cout << endl;
}
void sieve(long long n, vector<bool> &prime) {
  prime[0] = false;
  prime[1] = false;
  for (long long i = 2; i * i <= n; i++) {
    if (prime[i] == true) {
      for (long long j = i * i; j <= n; j += i) prime[j] = false;
    }
  }
}
int32_t main() {
  long long t = 1;
  while (t--) {
    long long n;
    cin >> n;
    vector<long long> v(n);
    for (long long i = (long long)0; i <= (long long)n - 1; i++) cin >> v[i];
    vector<long long> w;
    set<long long> s, sp;
    if (v[0] < 0 || v.size() == 1) {
      cout << -1;
      return 0;
    }
    s.insert(v[0]);
    sp.insert(v[0]);
    for (long long i = (long long)1; i <= (long long)n - 1; i++) {
      if (v[i] > 0) {
        if (sp.empty() || sp.find(v[i]) == sp.end()) {
          s.insert(v[i]);
          sp.insert(v[i]);
        } else {
          cout << -1;
          return 0;
        }
      } else {
        if (s.find(-1 * v[i]) == s.end()) {
          cout << -1;
          return 0;
        } else {
          auto it = s.find(-1 * v[i]);
          s.erase(it);
        }
      }
      if (s.size() == 0) {
        w.push_back(i + 1);
        s.clear();
        sp.clear();
      }
    }
    if (s.size() != 0) {
      cout << -1;
      return 0;
    }
    cout << w.size() << endl;
    for (long long i = (long long)w.size() - 1; i >= (long long)1; i--)
      w[i] -= w[i - 1];
    for (long long i = (long long)0; i <= (long long)w.size() - 1; i++)
      cout << w[i] << ' ';
  }
}
