#include <bits/stdc++.h>
using namespace std;
vector<long long> ans;
bool solve(long long n) {
  long long total = 0, cnt = 0;
  unordered_map<long long, long long> ump;
  for (long long i = 0; i < n; i++) {
    long long temp;
    cin >> temp;
    if (temp > 0) {
      if (ump[temp] != 0) return false;
      ump[temp] = 1;
      total++;
      cnt++;
    } else {
      if (ump[abs(temp)] != 1) return false;
      ump[abs(temp)] = -1;
      total--;
      cnt++;
    }
    if (total == 0) {
      ans.push_back(cnt);
      cnt = 0;
      ump.clear();
    }
  }
  if (ump.size() > 0) return false;
  return true;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  bool fg = solve(n);
  if (!fg)
    cout << "-1";
  else {
    cout << ans.size() << "\n";
    for (auto it : ans) cout << it << " ";
  }
}
