#include <bits/stdc++.h>
using namespace std;
long long mod = 998244353;
template <class T>
bool ckmin(T& a, const T& b) {
  return b < a ? a = b, 1 : 0;
}
template <class T>
bool ckmax(T& a, const T& b) {
  return a < b ? a = b, 1 : 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  long long arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  set<long long> st;
  map<long long, long long> mp;
  long long cnt = 0, flag = 1, num = 0;
  vector<long long> ans;
  for (int i = 0; i < n; i++) {
    num++;
    if (arr[i] > 0) {
      if (mp[arr[i]] >= 1) {
        if ((long long)st.size() == 0) {
          cnt++;
          ans.push_back(num - 1);
          num = 1;
          st.clear();
          mp.clear();
          st.insert(arr[i]);
          mp[arr[i]]++;
        } else {
          flag = 0;
          break;
        }
      } else {
        st.insert(arr[i]);
        mp[arr[i]]++;
      }
    } else {
      long long val = (-1) * arr[i];
      if ((long long)st.size() > 0 && st.find(val) != st.end()) {
        st.erase(val);
      } else {
        flag = 0;
        break;
      }
      if (st.size() == 0 && num != 0) {
        cnt++;
        ans.push_back(num);
        st.clear();
        mp.clear();
        num = 0;
      }
    }
  }
  if (num > 0) {
    cnt++;
    ans.push_back(num);
  }
  if ((long long)st.size() > 0) {
    flag = 0;
  }
  if (flag == 0) {
    cout << "-1";
  } else {
    cout << cnt << "\n";
    for (int i = 0; i < (long long)ans.size(); i++) {
      cout << ans[i] << " ";
    }
  }
}
