#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 9;
const long long N = 1e6 + 5;
long long powermodm(long long x, long long n, long long M) {
  long long result = 1;
  while (n > 0) {
    if (n % 2 == 1) result = (result * x) % M;
    x = (x * x) % M;
    n = n / 2;
  }
  return result;
}
long long power(long long _a, long long _b) {
  long long _r = 1;
  while (_b) {
    if (_b % 2 == 1) _r = (_r * _a);
    _b /= 2;
    _a = (_a * _a);
  }
  return _r;
}
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long lcm(long long a, long long b) {
  return (max(a, b) / gcd(a, b)) * min(a, b);
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  long long a[n];
  for (long long i = 0; i < n; i++) cin >> a[i];
  vector<long long> ans;
  long long flag = 1, c = 0;
  long long arr[N] = {0};
  set<long long> ms;
  for (long long i = 0; i < n; i++) {
    if (a[i] > 0) {
      if (arr[a[i]] == 0) {
        arr[a[i]]++;
        ms.insert(a[i]);
      } else
        flag = 0;
    } else {
      if (arr[abs(a[i])] == 1) {
        arr[abs(a[i])] = 0;
        ms.erase(abs(a[i]));
      } else
        flag = 0;
    }
    c++;
    if (flag == 0) break;
    if (ms.empty()) {
      ans.push_back(c);
      c = 0;
    }
  }
  if (!ms.empty()) flag = 0;
  set<long long> st[ans.size()];
  long long p = 0;
  for (long long i = 0; i < ans.size(); i++) {
    for (long long j = p; j < p + ans[i]; j++) st[i].insert(a[j]);
    p = p + ans[i];
  }
  for (long long i = 0; i < ans.size(); i++) {
    if (ans[i] != st[i].size()) flag = 0;
  }
  if (flag) {
    cout << ans.size() << endl;
    for (long long i = 0; i < ans.size(); i++) cout << ans[i] << " ";
  } else
    cout << -1;
  return 0;
}
