#include <bits/stdc++.h>
using namespace std;
int n;
set<int> s;
vector<int> ans;
int a[100005];
map<int, int> M;
int main() {
  cin >> n;
  int x;
  bool sign = true;
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  ans.push_back(0);
  for (int i = 1; i <= n; i++) {
    if (a[i] > 0) {
      if (s.find(a[i]) != s.end()) {
        sign = false;
        break;
      } else
        s.insert(a[i]);
    } else {
      if (s.find(-a[i]) == s.end()) {
        sign = false;
        break;
      } else {
        s.erase(-a[i]);
        if (s.size() == 0) {
          for (int j = ans[ans.size() - 1] + 1; j <= i; j++) M[a[j]]++;
          map<int, int>::iterator it;
          for (it = M.begin(); it != M.end(); it++) {
            if (it->second > 1) {
              sign = false;
              break;
            }
          }
          if (!sign) break;
          M.clear();
          ans.push_back(i);
        }
      }
    }
  }
  if (s.size()) sign = false;
  if (sign) {
    cout << ans.size() - 1 << endl;
    for (int i = 1; i < ans.size(); i++) printf("%d ", ans[i] - ans[i - 1]);
  } else
    cout << -1 << endl;
  return 0;
}
