#include <bits/stdc++.h>
using namespace std;
const int N = 200200;
int n;
bool was[N];
int a[N];
void solve() {
  int n;
  cin >> n;
  vector<int> ans;
  set<int> A, B;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (x > 0) {
      if (B.count(x)) {
        cout << -1 << endl;
        return;
      }
      A.insert(x);
      B.insert(x);
    } else {
      x = -x;
      if (A.count(x)) {
        A.erase(x);
      } else {
        cout << -1 << endl;
        return;
      }
      if (A.size() == 0) {
        ans.push_back(int(B.size()) * 2);
        B.clear();
      }
    }
  }
  if (A.size() > 0) {
    cout << -1 << endl;
    return;
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) cout << ans[i] << ' ';
}
int main() {
  int t;
  solve();
  return 0;
}
