#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long powmod(long long a, long long b, long long p) {
  if (b == 0) return 1;
  if (b == 1) return a;
  long long temp = powmod(a, b / 2, p);
  temp *= temp;
  temp %= p;
  if (b % 2 == 0) return temp;
  temp = temp * a;
  temp %= p;
  return temp;
}
void solve() {
  long long n, cur = 0, s = 0;
  cin >> n;
  unordered_set<long long> st;
  long long a[n];
  vector<long long> ans;
  ans.push_back(-1);
  for (__typeof((n)) i = (0); i < (n); i++) {
    cin >> a[i];
    s += a[i];
    if (a[i] < 0) {
      if (st.find(abs(a[i])) == st.end()) {
        cout << -1 << endl;
        return;
      } else
        cur -= 1;
    } else {
      if (st.find(a[i]) != st.end()) {
        cout << -1 << endl;
        return;
      }
      cur += 1;
      st.insert(a[i]);
    }
    if (s == 0 && cur == 0) {
      ans.push_back(i);
      st.clear();
    }
  }
  if (s != 0) {
    cout << -1 << endl;
    return;
  }
  cout << ans.size() - 1 << endl;
  for (__typeof((ans.size())) i = (1); i < (ans.size()); i++) {
    cout << ans[i] - ans[i - 1] << " ";
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
