#include <bits/stdc++.h>
using namespace std;
const int maxn = 100006;
int n;
int a[maxn];
bool vis[1000006];
bool first[1000006];
vector<int> vec;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  if (n & 1) {
    puts("-1");
    return 0;
  }
  int cnt = 0;
  vec.push_back(0);
  for (int i = 1; i <= n; i++) {
    if (a[i] > 0) {
      if (vis[a[i]] || first[a[i]]) {
        puts("-1");
        return 0;
      }
      first[a[i]] = 1;
      vis[a[i]] = 1;
      cnt++;
    } else {
      if (!vis[-a[i]]) {
        puts("-1");
        return 0;
      }
      vis[-a[i]] = 0;
      cnt--;
      if (cnt == 0) {
        for (int j = i; j > vec.back(); j--)
          if (a[j] > 0) first[a[j]] = 0;
        vec.push_back(i);
      }
    }
  }
  if (cnt) {
    puts("-1");
    return 0;
  }
  printf("%d\n", (int)vec.size() - 1);
  for (int i = 1; i < (int)vec.size(); i++) printf("%d ", vec[i] - vec[i - 1]);
  return 0;
}
