#include <bits/stdc++.h>
using namespace std;
const long long inf = (long long)1e18;
long long int pw(long long int x, unsigned long long int y) {
  if (y == 0)
    return 1;
  else if (y % 2 == 0)
    return pw(x, y / 2) * pw(x, y / 2);
  else
    return x * pw(x, y / 2) * pw(x, y / 2);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  map<long long int, long long int> mm, nn;
  vector<long long int> v;
  bool ok = true;
  long long int n, day, s, l;
  cin >> n;
  long long int a[n];
  day = 0;
  s = 0;
  l = 0;
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] > 0)
      mm[a[i]]++;
    else
      nn[a[i]]++;
    s += a[i];
    l++;
    if (nn[a[i]] > mm[abs(a[i])])
      ok = false;
    else if (nn[a[i]] > 1 || mm[a[i]] > 1)
      ok = false;
    if (s == 0) {
      v.push_back(l);
      l = 0;
      mm.clear();
      nn.clear();
    }
  }
  if (s != 0) ok = false;
  if (ok) {
    cout << v.size() << '\n';
    for (long long int i = 0; i < v.size(); i++) cout << v[i] << ' ';
    cout << '\n';
  } else
    cout << "-1";
  return 0;
}
