#include <bits/stdc++.h>
using namespace std;
int n, a[100005];
set<int> s;
vector<int> ans;
int main() {
  cin >> n;
  int cnt = 0, bal = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    cnt++;
    if (a[i] < 0) {
      bal--;
      if (*s.lower_bound(-a[i]) != -a[i] || *s.lower_bound(a[i]) == a[i]) {
        cout << -1;
        return 0;
      } else
        s.insert(a[i]);
    } else {
      bal++;
      if (*s.lower_bound(a[i]) == a[i]) {
        cout << -1;
        return 0;
      }
      s.insert(a[i]);
    }
    if (bal < 0) {
      cout << -1;
      return 0;
    }
    if (bal == 0) {
      ans.push_back(cnt);
      cnt = 0;
      s.clear();
    }
  }
  if (bal == 0) {
    cout << ans.size() << endl;
    for (int i : ans) cout << i << " ";
  } else
    cout << -1;
}
