#include <bits/stdc++.h>
using namespace std;
const int e = 100005;
const long long INF = 1e18 + 5;
template <typename T>
void show(T &a, int n) {
  for (long long i = 0; i < n; i++) cout << a[i] << " ";
  cout << "\n";
}
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (long long i = 0; i < n; i++) cin >> a[i];
  ;
  long long p = 0;
  vector<int> ans;
  set<int> s;
  for (long long i = 0; i < n; i++) {
    if (a[i] > 0) {
      if (s.find(a[i]) == s.end()) {
        s.insert(a[i]);
        p = p + a[i];
      } else {
        cout << -1 << "\n";
        return;
      }
    }
    if (a[i] < 0) {
      int pos = -a[i];
      if (s.find(pos) != s.end()) {
        p = p + a[i];
      } else {
        cout << -1 << "\n";
        return;
      }
    }
    if (p == 0) {
      ans.push_back(2 * s.size());
      s.clear();
    }
  }
  if (s.size() != 0) {
    cout << -1 << "\n";
    return;
  }
  cout << ans.size() << "\n";
  for (int k : ans) cout << k << " ";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int t;
  solve();
  return 0;
}
