#include <bits/stdc++.h>
using namespace std;
int main() {
  long int co = 0, i, n, y, m, j, k, t, x = 0;
  cin >> n;
  int a[n + 1];
  for (i = 1; i <= n; i++) cin >> a[i];
  co = 0;
  int c = 1;
  j = 0;
  vector<int> v;
  map<int, int> mp;
  for (i = 1; i <= n; i++) {
    mp[a[i]]++;
    co += a[i];
    j++;
    if (a[i] < 0) {
      if (mp[-1 * a[i]] != 1) {
        co = -1;
        break;
      }
    }
    if (mp[a[i]] > 1) {
      c = 0;
      break;
    }
    if (co == 0) {
      v.push_back(j);
      mp.clear();
      j = 0;
      co = 0;
    }
  }
  if (!co) {
    if (c) {
      cout << v.size() << '\n';
      for (int i = 0; i < v.size(); i++) {
        cout << v[i] << ' ';
      }
    } else
      cout << -1 << '\n';
  } else
    cout << -1 << '\n';
}
