#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int arr[N];
vector<int> ans;
set<int> cur, tot;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
  }
  int bef = 0;
  for (int i = 0; i < n; ++i) {
    if (arr[i] > 0) {
      if (cur.count(arr[i]) || tot.count(arr[i])) return puts("-1");
      cur.insert(arr[i]);
    } else {
      if (!cur.count(-arr[i])) return puts("-1");
      cur.erase(-arr[i]);
      tot.insert(-arr[i]);
    }
    if (cur.empty()) {
      ans.push_back(i - bef + 1);
      cur.clear();
      tot.clear();
      bef = i + 1;
    }
  }
  if (!cur.empty()) return puts("-1");
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); ++i)
    printf("%d%c", ans[i], " \n"[i + 1 == ans.size()]);
  return 0;
}
