#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e6 + 5;
int sum[maxn];
int vis[maxn];
int day[maxn];
int main() {
  int n;
  cin >> n;
  int in = 0;
  int s = 0;
  int cnt = 0;
  int flag = 0;
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    if (a > 0) {
      if (vis[a] == 0) {
        if (day[a] == cnt + 1) {
          flag = 1;
        }
        day[a] = cnt + 1;
        vis[a] = 1;
        in++;
        s++;
      } else {
        flag = 1;
      }
    } else {
      a = -a;
      if (vis[a] == 1) {
        vis[a] = 0;
        in--;
        s++;
        if (in == 0) {
          sum[cnt++] = s;
          s = 0;
        }
      } else
        flag = 1;
    }
  }
  if (in != 0 || flag) {
    cout << "-1" << endl;
  } else {
    cout << cnt << endl;
    for (int i = 0; i < cnt; i++) {
      cout << sum[i] << ' ';
    }
  }
  return 0;
}
