#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int state[N] = {};
int main() {
  int n;
  cin >> n;
  int a[n], cnt = 0, ans = 0;
  std::vector<int> cur, res;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    int x = abs(a[i]);
    cur.push_back(x);
    if (a[i] > 0) {
      if (state[x] != 0) {
        ans = 1;
        break;
      }
      state[x] = 1;
      cnt++;
    } else {
      if (state[x] != 1) {
        ans = 1;
        break;
      }
      state[x] = 2;
      cnt--;
    }
    if (cnt == 0) {
      res.push_back(cur.size());
      for (int c : cur) state[c] = 0;
      cur.clear();
    }
  }
  if (ans == 1 || !cur.empty())
    cout << -1 << endl;
  else {
    cout << res.size() << endl;
    for (int i = 0; i < res.size(); i++) cout << res[i] << " ";
    cout << endl;
  }
  return 0;
}
