#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
  ios_base::sync_with_stdio(false);
  while (cin >> n) {
    vector<int> inside(1000006, 0), ans;
    int stack = 0, length = 0, x, valid = 1, j = 1;
    unordered_map<int, int> used;
    for (int i = 0; i < n; ++i) {
      cin >> x;
      if ((x > 0 && inside[x]) || (x < 0 && !inside[-x]) ||
          (x > 0 && used[x])) {
        valid = 0;
      } else if (x > 0) {
        ++inside[x];
        ++stack;
        ++length;
        used[x] = j++;
      } else if (x < 0) {
        --inside[-x];
        --stack;
        ++length;
      }
      if (!stack && valid) {
        ans.emplace_back(length);
        length = 0;
        used.clear();
      }
    }
    if (stack) valid = 0;
    if (valid) {
      cout << ans.size() << endl;
      for (int i : ans) cout << i << " ";
      cout << endl;
    } else {
      cout << -1 << endl;
    }
  }
  return 0;
}
