#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 45;
int n;
int a[N];
map<int, int> mapa;
vector<int> v;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int bal = 0, pos = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] < 0) {
      if (!mapa[-a[i]]) {
        cout << -1 << endl;
        return 0;
      }
      mapa[a[i]] = 1;
      mapa[-a[i]] = 0;
      bal--;
    } else {
      if (mapa[a[i]] || mapa[-a[i]]) {
        cout << -1 << endl;
        return 0;
      }
      mapa[a[i]] = 1;
      bal++;
    }
    if (bal == 0) {
      v.push_back(i - pos);
      pos = i;
      bal = 0;
      mapa.clear();
    }
  }
  if (bal != 0) {
    cout << -1 << endl;
    return 0;
  }
  cout << v.size() << endl;
  for (auto f : v) {
    cout << f << " ";
  }
  cout << endl;
}
