#include <bits/stdc++.h>
using namespace std;
bool isSorted(vector<int> &arr, int i) {
  bool f1 = true, f2 = true;
  for (int j = 0; j <= i; j++) {
    if (arr[j] != (j + 1)) {
      f1 = false;
      break;
    }
  }
  for (int j = i + 1; j < arr.size(); j++) {
    if (arr[j] != (j + 1)) {
      f2 = false;
      break;
    }
  }
  if (i == arr.size() - 1) {
    f2 = false;
  }
  return (f1 or f2);
}
void solve() {
  int n;
  cin >> n;
  vector<int> arr(n);
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  if (is_sorted(arr.begin(), arr.end())) {
    cout << 0 << endl;
    return;
  } else if (arr[0] == n and arr[n - 1] == 1) {
    cout << 3 << endl;
    return;
  }
  for (int i = 0; i < n; i++) {
    if (isSorted(arr, i)) {
      cout << 1 << endl;
      return;
    }
  }
  cout << 2 << endl;
}
void solveA() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  if (a == b) {
    cout << "YES" << endl;
    return;
  }
  bool f1 = false;
  set<int> s;
  for (int i = 0; i < n; i++) {
    if (a[i] > b[i]) {
      f1 = true;
    } else if (a[i] != b[i]) {
      s.insert(b[i] - a[i]);
    }
  }
  if (f1 or (s.size() > 1)) {
    cout << "NO" << endl;
  } else {
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      if (a[i] != b[i]) {
        if (i == 0 or (a[i - 1] == b[i - 1])) {
          cnt++;
        }
      }
      if (cnt > 1) {
        cout << "NO" << endl;
        return;
      }
    }
    cout << "YES" << endl;
  }
}
void solveB() {
  int n;
  cin >> n;
  vector<int> arr(n);
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  if (n & 1) {
    cout << -1 << endl;
    return;
  }
  set<int> in, exit;
  vector<int> days;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (arr[i] < 0) {
      if (in.find(-arr[i]) != in.end()) {
        in.erase(-arr[i]);
        exit.insert(-arr[i]);
        cnt++;
      } else {
        cout << -1 << endl;
        return;
      }
    } else {
      if (exit.find(arr[i]) != exit.end()) {
        cout << -1 << endl;
        return;
      } else {
        in.insert(arr[i]);
        cnt++;
      }
    }
    if (in.empty()) {
      days.push_back(cnt);
      cnt = 0;
      exit.clear();
    }
  }
  if (in.empty() == false) {
    cout << -1 << endl;
    return;
  }
  if (cnt) {
    days.push_back(cnt);
  }
  cout << days.size() << endl;
  for (int i : days) {
    cout << i << " ";
  }
  cout << endl;
  return;
}
int main() {
  int T = 1;
  while (T--) {
    solveB();
  }
}
