#include <bits/stdc++.h>
#pragma GCC optimize(3, "Ofast", "inline")
using namespace std;
const int maxn = (long long)1e6 + 5;
const int mod = 1000000007;
const int inf = 0x3f3f3f3f;
bool vis[maxn];
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int n;
  cin >> n;
  vector<int> v;
  int now = 0;
  int s = 0;
  unordered_map<int, bool> m;
  for (int i = 1; i <= n; ++i) {
    ++s;
    int x;
    cin >> x;
    if (x > 0) {
      if (m[x]) {
        cout << -1;
        return 0;
      }
      if (vis[x]) {
        cout << -1;
        return 0;
      } else {
        ++now;
        vis[x] = true;
        m[x] = true;
      }
    } else {
      if (vis[-x]) {
        --now;
        vis[-x] = false;
        if (now == 0) {
          v.push_back(s);
          s = 0;
          m.clear();
        }
      } else {
        cout << -1;
        return 0;
      }
    }
  }
  if (now) {
    cout << -1;
    return 0;
  }
  cout << v.size() << '\n';
  for (auto &i : v) cout << i << ' ';
  return 0;
}
