#include <bits/stdc++.h>
using namespace std;
vector<int64_t> solve(const int64_t N, const vector<int64_t>& A) {
  vector<int64_t> ans;
  int64_t c = 0;
  set<int64_t> employees_in_office;
  set<int64_t> employees_in_day;
  for (int64_t i = 0; i < N; ++i) {
    if (A[i] > 0) {
      if (employees_in_day.find(A[i]) == employees_in_day.end()) {
        if (!employees_in_office.empty()) {
          employees_in_day.insert(A[i]);
          employees_in_office.insert(A[i]);
          c++;
        } else {
          employees_in_day.clear();
          if (c > 0) {
            ans.push_back(c);
            c = 0;
          }
          c++;
          employees_in_office.insert(A[i]);
          employees_in_day.insert(A[i]);
        }
      } else {
        if (!employees_in_office.empty()) {
          return vector<int64_t>();
        }
        employees_in_day.clear();
        if (c > 0) {
          ans.push_back(c);
          c = 0;
        }
        c++;
        employees_in_office.insert(A[i]);
        employees_in_day.insert(A[i]);
      }
    } else {
      if (employees_in_office.find(-A[i]) == employees_in_office.end()) {
        return vector<int64_t>();
      }
      employees_in_office.erase(-A[i]);
      c++;
    }
  }
  if (!employees_in_office.empty()) {
    return vector<int64_t>();
  }
  if (c > 0) {
    ans.push_back(c);
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  const unsigned seed = chrono::system_clock::now().time_since_epoch().count();
  mt19937 gen(seed);
  int64_t N;
  cin >> N;
  ;
  vector<int64_t> A(N);
  for (int64_t i = 0; i < N; ++i) {
    cin >> A[i];
  }
  const vector<int64_t> ans(solve(N, A));
  if (ans.empty()) {
    cout << "-1\n";
  } else {
    cout << ans.size() << "\n";
    for (int64_t i = 0; i < ans.size(); ++i) {
      cout << ans[i];
      if (i + 1 < ans.size()) {
        cout << " ";
      } else {
        cout << "\n";
      }
    }
  }
  return 0;
}
