#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int N_MAX = 1e6 + 5;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, people = 0, last = -1, day_index = 0;
  cin >> N;
  vector<int> events, day(N_MAX, -1);
  vector<bool> present(N_MAX, false);
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    if (a > 0) {
      if (present[a] || day[a] == day_index) {
        cout << -1 << '\n';
        return 0;
      }
      present[a] = true;
      people++;
      day[a] = day_index;
    } else {
      a = -a;
      if (!present[a] || day[a] != day_index) {
        cout << -1 << '\n';
        return 0;
      }
      present[a] = false;
      people--;
      if (people == 0) {
        events.push_back(i - last);
        last = i;
        day_index++;
      }
    }
  }
  if (people != 0) {
    cout << -1 << '\n';
    return 0;
  }
  if (last < N - 1) events.push_back(N - 1 - last);
  cout << events.size() << '\n';
  for (int i = 0; i < (int)events.size(); i++)
    cout << events[i] << (i < (int)events.size() - 1 ? ' ' : '\n');
}
