#include <bits/stdc++.h>
using namespace std;
long long M = 1e9 + 7;
double pi = acos(-1.0);
long long powerm(long long x, long long y) {
  long long res = 1;
  while (y) {
    if (y & 1) res = (res * x) % M;
    y = y >> 1;
    x = (x * x) % M;
  }
  return res % M;
}
long long power(long long x, long long y) {
  long long res = 1;
  while (y) {
    if (y & 1) res = (res * x);
    y = y >> 1;
    x = (x * x);
  }
  return res;
}
long long max3(long long a, long long b, long long c) {
  return max(max(a, b), c);
}
long long gcd(long long a, long long b) {
  if (b > a) return gcd(b, a);
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  int prev = 0;
  int cnt = 0;
  vector<int> pp;
  map<int, int> m;
  set<int> s;
  for (int i = 0; i < n; i++) {
    if (a[i] > 0) {
      if (m[a[i]]) goto bad;
      if (s.count(a[i])) goto bad;
      cnt++;
      m[a[i]] = 1;
      s.insert(a[i]);
    } else {
      int p = -a[i];
      if (!m[p]) goto bad;
      m[p] = 0;
      cnt--;
      if (cnt == 0) {
        pp.push_back(i - prev + 1);
        prev = i + 1;
        s.clear();
      }
    }
  }
  if (cnt != 0) goto bad;
  cout << pp.size() << '\n';
  for (auto it : pp) cout << it << ' ';
  return 0;
bad:
  cout << -1;
  return 0;
}
