#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, cnt = 0, flag = 0;
  cin >> n;
  int a[n];
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  vector<int> v;
  if (sum != 0) {
    flag = 1;
  } else {
    long long pref = 0;
    set<int> s;
    for (int i = 0; i < n; i++) {
      if (a[i] < 0 && s.find(abs(a[i])) == s.end()) {
        flag = 1;
        break;
      }
      if (s.size() > 0 && a[i] > 0 && s.find(a[i]) != s.end()) {
        flag = 1;
        break;
      }
      pref += a[i];
      s.insert(a[i]);
      if (pref == 0) {
        cnt++;
        v.push_back(s.size());
        s.clear();
      }
    }
  }
  if (flag) {
    cout << -1 << "\n";
  } else {
    cout << cnt << "\n";
    for (auto it : v) {
      cout << it << " ";
    }
    cout << "\n";
  }
  return 0;
}
