#include <bits/stdc++.h>
using namespace std;
int stk[1000009];
map<int, int> mp;
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int x, sum = 0, cnt = 0;
  vector<int> ans;
  for (int i = 0; i < n; i++) {
    x = a[i];
    if (x > 0) {
      if (stk[x] != 0) {
        cout << -1;
        return 0;
      }
      if (mp[x] == 1) {
        cout << -1;
        return 0;
      }
      stk[x] = 1;
      mp[x] = 1;
      sum++;
    } else {
      if (stk[-x] == 0) {
        cout << -1;
        return 0;
      }
      stk[-x] = 0;
      sum--;
    }
    cnt++;
    if (sum == 0) {
      ans.push_back(cnt);
      cnt = 0;
      mp.clear();
    }
  }
  if (sum != 0) {
    cout << -1;
    return 0;
  }
  int sz = ans.size();
  cout << sz << endl;
  for (int i = 0; i < sz; i++) {
    cout << ans[i] << endl;
  }
}
