#include <bits/stdc++.h>
using namespace std;
long long n;
long long a[200004];
int in[1000004], out[1000004];
int main() {
  memset(in, 0, sizeof(in));
  memset(out, 0, sizeof(out));
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  int cnt = 0, d = 0, day = 1;
  vector<int> ans;
  for (int i = 0; i < n; i++) {
    if (a[i] > 0) {
      if (in[a[i]] == day) {
        cout << "-1";
        return 0;
      }
      cnt++;
      in[a[i]] = day;
      d++;
    }
    if (a[i] < 0) {
      if (in[-a[i]] != day || out[-a[i]] == day) {
        cout << "-1";
        return 0;
      }
      cnt--;
      out[-a[i]] = day;
    }
    if (!cnt) {
      ans.push_back(2 * d);
      d = 0;
      day++;
    }
  }
  if (cnt > 0) {
    cout << "-1";
    return 0;
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) cout << ans[i] << ' ';
  return 0;
}
