#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MAXN = 1e5 + 5;
int n, m;
int a[MAXN];
unordered_map<int, int> vis;
int has[MAXN * 10];
vector<pair<int, int> > ans;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  int last = 1;
  for (int i = 1; i <= n; i++) {
    if (a[i] > 0) {
      if (has[a[i]] == 0 && vis.count(a[i]) == 0) {
        has[a[i]] = 1;
        vis[a[i]] = 1;
        m++;
      } else {
        puts("-1");
        return 0;
      }
    } else {
      if (has[-1 * a[i]] != 1) {
        puts("-1");
        return 0;
      } else {
        has[-1 * a[i]] = 0;
        m--;
      }
    }
    if (m == 0) {
      ans.push_back(pair<int, int>(last, i));
      last = i + 1;
      vis.clear();
    }
  }
  if (m > 0) {
    puts("-1");
    return 0;
  }
  cout << ans.size() << endl;
  for (auto it : ans) {
    cout << it.second - it.first + 1 << " ";
  }
  puts("");
  return 0;
}
