#include <bits/stdc++.h>
using namespace std;
long long MOD = 1e9 + 7;
long long arrA[100005], arrB[100005];
int main() {
  long long n, prevI = 0, x, oneCount = 0, flag = 0;
  cin >> n;
  vector<long long> vec;
  map<long long, long long> mp1;
  for (int i = 0; i < n; i++) {
    cin >> x;
    if (!flag) {
      if (x > 0) {
        if (mp1[x] == 0) {
          mp1[x]++;
          oneCount++;
        } else {
          flag = 1;
        }
      } else if (x < 0) {
        if (mp1[abs(x)] == 1) {
          mp1[abs(x)] = 2;
          oneCount--;
          if (oneCount == 0) {
            vec.push_back((i - prevI) + 1);
            prevI = i + 1;
            mp1.clear();
          }
        } else {
          flag = 1;
        }
      }
    }
  }
  if (flag)
    cout << -1 << endl;
  else if (oneCount > 0)
    cout << -1 << endl;
  else {
    cout << vec.size() << endl;
    for (int i = 0; i < vec.size(); i++) {
      cout << vec[i] << " ";
    }
  }
}
