#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  vector<int> ans;
  map<int, int> mp;
  int t = 0, p = 1, x;
  for (auto i = 0; i <= n - 1; i++) {
    cin >> x;
    if (x > 0) {
      int y = mp[x];
      if (y == 0 || y != -p && y != p) {
        t++;
        mp[x] = p;
      } else {
        cout << -1;
        return 0;
      }
    } else {
      int y = mp[-x];
      x = -x;
      if (y == p) {
        mp[x] = -p;
        t--;
        if (t == 0) {
          ans.push_back(i + 1);
          p++;
        }
      } else {
        cout << -1;
        return 0;
      }
    }
  }
  if (t != 0) {
    cout << -1;
    return 0;
  } else {
    cout << ans.size() << endl;
    int temper = 0;
    for (auto i = 0; i <= ans.size() - 1; i++) {
      cout << ans[i] - temper << " ";
      temper = ans[i];
    }
  }
  return 0;
}
