#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, i, j;
  cin >> n;
  long long int a[n];
  for (i = 0; i < n; i++) cin >> a[i];
  set<long long int> s1, s2;
  long long int cnt = 0, flag = 0;
  vector<long long int> ans;
  for (i = 0; i < n; i++) {
    cnt++;
    if (a[i] > 0) {
      if (s1.count(a[i])) {
        flag = 1;
        break;
      }
      s1.insert(a[i]);
      s2.insert(a[i]);
    } else {
      a[i] = -a[i];
      if (!s2.count(a[i])) {
        flag = 1;
        break;
      }
      s2.erase(a[i]);
    }
    if (s2.empty()) {
      ans.push_back(cnt);
      cnt = 0;
      s1.clear();
    }
  }
  if (flag || !s1.empty() || !s2.empty())
    cout << "-1\n";
  else {
    cout << ans.size() << "\n";
    for (i = 0; i < ans.size(); i++) cout << ans[i] << " ";
    cout << "\n";
  }
}
