#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int arr[100100];
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> arr[i];
  set<int> s, mark;
  vector<int> res;
  for (int i = 1; i <= n; ++i) {
    if (arr[i] > 0) {
      if (s.count(arr[i]) || mark.count(arr[i])) {
        cout << "-1" << endl;
        return 0;
      }
      mark.insert(arr[i]);
      s.insert(arr[i]);
    } else if (arr[i] < 0) {
      if (!s.count(-arr[i])) {
        cout << "-1" << endl;
        return 0;
      }
      s.erase(-arr[i]);
    }
    if (s.size() == 0) {
      res.push_back(i);
      mark.clear();
    }
  }
  if (s.size() > 0)
    cout << -1 << endl;
  else {
    int prev = 0;
    cout << res.size() << endl;
    for (auto el : res) {
      cout << el - prev << ' ';
      prev = el;
    }
    cout << endl;
  }
  return 0;
}
