#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  ll n, i, j, count, total = 0, k = 1, st, ed;
  cin >> n;
  ll arr[n];
  for (i = 0; i < n; i++) {
    cin >> arr[i];
  }
  if (n & 1) {
    cout << -1;
    return 0;
  }
  i = 0;
  map<ll, ll> vis;
  vector<ll> ans;
  count = 0;
  while (i < n) {
    if (count == 0) {
      st = i;
    }
    if (arr[i] > 0 and vis[arr[i]] == 0) {
      count++;
      vis[arr[i]] = 1;
    } else if (arr[i] < 0 and vis[-arr[i]] == 1) {
      count--;
      vis[-arr[i]]++;
    } else if (arr[i] < 0 and vis[-arr[i]] != 1) {
      k = 0;
      break;
    }
    if (count == 0) {
      ed = i;
      vis.clear();
      total = total + abs(st - ed) + 1;
      ans.push_back(abs(st - ed) + 1);
    }
    i++;
  }
  if (k == 0) {
    cout << -1;
  } else if (count != 0 or total != n) {
    cout << -1;
  } else {
    cout << ans.size() << '\n';
    for (auto v : ans) cout << v << " ";
  }
  return 0;
}
