#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n;
  cin >> n;
  long long int a[n];
  for (long long int i = 0; i < n; i++) cin >> a[i];
  vector<long long int> v;
  set<long long int> st;
  long long int ans = 0, sum = 0;
  long long int j = 0;
  for (; j < n; j++) {
    if (a[j] < 0) {
      if (st.find(-a[j]) != st.end()) {
        ans++;
        sum += a[j];
        if (sum == 0) {
          v.push_back(ans);
          ans = 0;
          st.clear();
        }
      } else {
        cout << "-1\n";
        return 0;
      }
    } else if (a[j] > 0) {
      if (st.find(a[j]) == st.end()) {
        st.insert(a[j]);
        sum += a[j];
        ans++;
      } else {
        if (ans != 2 * st.size()) {
          cout << "-1\n";
          return 0;
        }
        v.push_back(ans);
        ans = 0;
        st.clear();
        j--;
        sum = 0;
      }
    }
  }
  if (sum == 0) {
    if (ans > 0) v.push_back(ans);
  } else {
    cout << "-1\n";
    return 0;
  }
  cout << v.size() << "\n";
  for (auto b : v) cout << b << " ";
  cout << "\n";
}
