#include <bits/stdc++.h>
using namespace std;
const int ms = int(1e6) + 10;
int mark[ms];
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  int n, cur = 0, x, on = 0;
  cin >> n;
  vector<int> ans;
  set<int> cur_day;
  for (int i = 0; i < n; i++) {
    cur++;
    cin >> x;
    if (x > 0) {
      if (cur_day.count(x)) {
        cout << -1 << endl;
        return 0;
      } else {
        cur_day.insert(x);
        mark[x] = 1;
        on++;
      }
    } else {
      x = -x;
      if (mark[x]) {
        mark[x] = 0;
        on--;
        if (on == 0) {
          ans.push_back(cur);
          cur = 0;
          cur_day.clear();
          continue;
        }
      } else {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  if (cur || on) {
    cout << -1 << endl;
    return 0;
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++)
    cout << ans[i] << " \n"[i + 1 == ans.size()];
  return 0;
}
