#include <bits/stdc++.h>
using namespace std;
vector<int> ans, cache;
int f[1000100], a[100100], p[1000100];
int main() {
  int n, flag = 0, sum = 0, pre = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    if (a[i] > 0 && !f[a[i]]) {
      f[a[i]] = 1;
      if (p[a[i]]) flag = 1;
      p[a[i]] = 1;
      cache.push_back(a[i]);
      sum++;
    } else if (a[i] > 0 && f[a[i]])
      flag = 1;
    if (a[i] < 0 && !f[-a[i]])
      flag = 1;
    else if (a[i] < 0 && f[-a[i]]) {
      f[-a[i]] = 0;
      sum--;
      if (sum == 0) {
        ans.push_back(i - pre + 1);
        pre = i + 1;
        for (int j = 0; j < cache.size(); ++j) p[cache[j]] = 0;
        cache.clear();
      }
    }
  }
  if (n % 2 != 0) flag = 1;
  for (int i = 1; i < 1000100; ++i)
    if (f[i]) flag = 1;
  if (flag)
    printf("-1\n");
  else {
    printf("%d\n", ans.size());
    for (int i = 0; i < ans.size() - 1; ++i) printf("%d ", ans[i]);
    printf("%d\n", ans[ans.size() - 1]);
  }
  return 0;
}
