#include <bits/stdc++.h>
double PI = acos(-1.0);
using namespace std;
int mod = 1000000007;
int inf = INT_MAX;
int minf = INT_MIN;
int main() {
  int n;
  cin >> n;
  int a[n];
  long long int sum = 0, cnt = 0;
  vector<int> v;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    sum += a[i];
    if (sum < 0) {
      cout << "-1";
      return 0;
    }
  }
  if (sum != 0) {
    cout << "-1";
    return 0;
  }
  sum = 0;
  set<int> s;
  for (int i = 0; i < n; i++) {
    cnt++;
    if (a[i] > 0) {
      if (!s.count(a[i]))
        s.insert(a[i]);
      else {
        cout << "-1";
        return 0;
      }
    }
    if (a[i] < 0) {
      int x = (-1) * a[i];
      if (s.find(x) == s.end()) {
        cout << "-1";
        return 0;
      }
    }
    sum += a[i];
    if (sum == 0) {
      v.push_back(cnt);
      cnt = 0;
      s.clear();
    }
  }
  cout << v.size() << endl;
  for (int i : v) cout << i << " ";
}
