#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int n, a[100005], lastpos, kol[N], t;
set<int> q;
vector<int> ans;
bool us[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  int lastpos = 0;
  t = 0;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    int x = a[i];
    if (a[i] > 0)
      kol[x]++;
    else
      kol[-x]--;
    int s;
    if (x > 0)
      s = kol[x];
    else
      s = kol[-x];
    if (s < 0) return cout << -1, 0;
  }
  for (int i = 1; i <= 1000000; ++i)
    if (kol[i] != 0) return cout << -1, 0;
  for (int i = 1; i <= n; ++i) {
    int x = a[i];
    if (a[i] > 0) {
      if (kol[x] == 1) return cout << -1, 0;
      kol[x]++;
      t++;
      q.insert(x);
    } else {
      t--;
      if (t == 0) {
        ans.push_back(i - lastpos);
        lastpos = i;
        while (!q.empty()) {
          int y = *q.begin();
          kol[y] = 0;
          q.erase(y);
        }
      }
    }
  }
  if (lastpos != n) return cout << -1, 0;
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); ++i) cout << ans[i] << " ";
}
