#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  long long int i, a[n];
  for (i = 0; i < n; i++) cin >> a[i];
  long long int count = 0, l = 0, sum = 0, flag = 1;
  vector<int> vec;
  unordered_map<int, int> m;
  for (i = 0; i < n; i++) {
    m[(1000000 + a[i])]++;
    l++;
    sum += a[i];
    if (m[1000000 + a[i]] >= 2) {
      flag = 0;
      break;
    }
    if (a[i] < 0 && m[1000000 + abs(a[i])] == 0) {
      flag = 0;
      break;
    }
    if (i == n - 1 && sum != 0) {
      flag = 0;
      break;
    }
    if (sum == 0 && i != 0) {
      count++;
      vec.push_back(l);
      m.clear();
      l = 0;
    }
  }
  if (flag == 0)
    cout << -1 << endl;
  else {
    cout << count << endl;
    for (i = 0; i < count; i++) cout << vec[i] << " ";
    cout << endl;
  }
}
