#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
long long get_no(vector<long long> &arr, map<long long, long long> &m,
                 long long in) {
  m.clear();
  map<long long, long long> m2;
  long long i = in + 1, b = 0, n = ((long long)arr.size());
  if (arr[in] < 0) return -1;
  m[arr[in]]++;
  b++;
  while (i < n) {
    if (arr[i] > 0 and m[arr[i]] == 1) return -1;
    if (arr[i] < 0 and m[-1 * arr[i]] == m2[arr[i]]) return -1;
    if (arr[i] > 0) {
      m[arr[i]]++;
      b++;
    } else {
      m2[arr[i]]++;
      b--;
    }
    if (b == 0) return i;
    i++;
  }
  return -1;
}
void solve() {
  long long n;
  cin >> n;
  ;
  vector<long long> arr(n);
  for (long long i = 0; i < (long long)n; i++) {
    cin >> arr[i];
  };
  vector<long long> req;
  map<long long, long long> m;
  long long i = 0, c = 0, prev = 0, in;
  while (prev < n) {
    in = get_no(arr, m, prev);
    if (in == -1) {
      cout << -1;
      cout << '\n';
      ;
      return;
    } else {
      c++;
      req.push_back(in - prev + 1);
    }
    prev = in + 1;
  }
  cout << c;
  cout << '\n';
  ;
  for (long long i = 0; i < (long long)((long long)req.size()); i++)
    cout << req[i] << " ";
  cout << '\n';
  ;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  solve();
  return 0;
}
