#include <bits/stdc++.h>
using namespace std;
int n, a, bos, vbas;
int dizi[1000006], crr, dizim[1000006];
vector<int> v, vv;
int main() {
  scanf("%d", &n);
  v.push_back(0);
  crr = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a);
    if (a > 0) {
      dizim[a]++;
      vv.push_back(a);
      crr++;
      if (dizi[a] > 0 || dizim[a] > 1) {
        printf("-1\n");
        return 0;
      }
      dizi[a]++;
    } else {
      a = -a;
      crr--;
      if (dizi[a] != 1) {
        printf("-1\n");
        return 0;
      }
      dizi[a]--;
    }
    if (crr == 0) {
      bos = vv.size();
      for (int i = vbas; i < bos; i++) {
        dizim[vv[i]] = 0;
      }
      vbas = bos;
      v.push_back(i);
    }
  }
  if ((v.size() - 1) == 0 || crr != 0) {
    printf("-1\n");
    return 0;
  } else
    cout << (v.size() - 1) << endl;
  bos = v.size();
  for (int i = 1; i < bos; i++) {
    printf("%d ", v[i] - v[i - 1]);
  }
}
