#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int consum[n + 1];
  consum[0] = 0;
  vector<int> ans;
  ans.push_back(0);
  map<int, int> m;
  bool flag = false;
  for (long long int i = 1; i <= n; i++) {
    int num;
    cin >> num;
    m[num]++;
    if (m[num] > 1) flag = true;
    if (num < 0 && m[num * (-1)] != 1) flag = true;
    consum[i] = consum[i - 1] + num;
    if (consum[i] == 0) {
      m.clear();
      ans.push_back(i);
    }
  }
  if (ans.size() - 1 == 0 || flag || ans.back() != n) {
    cout << "-1\n";
    return 0;
  }
  cout << ans.size() - 1 << "\n";
  for (long long int i = 1; i <= ans.size() - 1; i++)
    cout << ans[i] - ans[i - 1] << " ";
  cout << "\n";
  fclose(stdin);
  fclose(stdout);
}
