#include <bits/stdc++.h>
using namespace std;
int n, cnt[1000001];
bool u[1000001];
set<int> s2;
set<int> s;
vector<int> v;
int main() {
  cin >> n;
  int l = 1;
  for (int i = 1; i <= n; i++) {
    int a;
    cin >> a;
    if (a > 0) {
      if (u[a] == 1) {
        cout << -1;
        return 0;
      }
      u[a] = 1;
      s.insert(a);
      int sz = s2.size();
      s2.insert(a);
      if ((int)s2.size() == sz) {
        cout << -1;
        return 0;
      }
    } else {
      a *= (-1);
      if (!u[a]) {
        cout << -1;
        return 0;
      }
      u[a] = 0;
      s.erase(a);
    }
    if (s.empty()) {
      if (i - l + 1 > 1) {
        v.push_back(i - l + 1);
        l = i + 1;
        s2.clear();
      }
    }
  }
  if (!s.empty()) {
    cout << -1;
    return 0;
  }
  cout << v.size() << '\n';
  for (auto to : v) {
    cout << to << " ";
  }
}
