New Year and the Acquaintance Estimation

Bob is an active user of the social network Faithbug. On this network, people are able to engage in a mutual friendship. That is, if $a$ is a friend of $b$, then $b$ is also a friend of $a$. Each user thus has a non-negative amount of friends.

This morning, somebody anonymously sent Bob the following link: graph realization problem and Bob wants to know who that was. In order to do that, he first needs to know how the social network looks like. He investigated the profile of every other person on the network and noted down the number of his friends. However, he neglected to note down the number of his friends. Help him find out how many friends he has. Since there may be many possible answers, print all of them.

Input

The first line contains one integer $n$ ($1 \leq n \leq 5 \cdot 10^5$), the number of people on the network excluding Bob.

The second line contains $n$ numbers $a_1,a_2, \dots, a_n$ ($0 \leq a_i \leq n$), with $a_i$ being the number of people that person $i$ is a friend of.

Output

Print all possible values of $a_{n+1}$ — the amount of people that Bob can be friend of, in increasing order.

If no solution exists, output $-1$.

Examples

input

3
3 3 3

output

3 

input

4
1 1 1 1

output

0 2 4 

input

2
0 2

output

-1

input

35
21 26 18 4 28 2 15 13 16 25 6 32 11 5 31 17 9 3 24 33 14 27 29 1 20 4 12 7 10 30 34 8 19 23 22

output

13 15 17 19 21 

Note

In the first test case, the only solution is that everyone is friends with everyone. That is why Bob should have $3$ friends.

In the second test case, there are three possible solutions (apart from symmetries):

  • $a$ is friend of $b$, $c$ is friend of $d$, and Bob has no friends, or
  • $a$ is a friend of $b$ and both $c$ and $d$ are friends with Bob, or
  • Bob is friends of everyone.

The third case is impossible to solve, as the second person needs to be a friend with everybody, but the first one is a complete stranger.

Solution:

#include <bits/stdc++.h>

using namespace std;

int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<int> d(n);
for (int i = 0; i < n; i++) {
    cin >> d[i];
}
sort(d.begin(), d.end());
vector<long long> pref(n + 1);
for (int i = 0; i < n; i++) {
    pref[i + 1] = pref[i] + d[i];
  }
  vector<int> bal(n + 2);
int j = 0;
for (int k = 1; k <= n; k++) {
    long long L = pref[n] - pref[n - k];
    long long R = (long long) k * (k - 1);
    while (j < n && d[j] < k) {
      j++;
    }
    int up = min(n - k, j);
    R += pref[up] + (long long) k * ((n - k) - up);
    int bound = d[n - k];
    { // <= bound
      long long diff = L - R;
      if (diff <= k && diff <= bound) {
        bal[max(diff, 0LL)]++;
        bal[bound + 1]--;
      }
    }
    { // > bound
L -= d[n - k];
R += min(d[n - k], k);
long long diff = R - L;
if (diff >= bound + 1) {
bal[bound + 1]++;
bal[min(diff + 1, n + 1LL)]--;
}
}
}
vector<int> res;
int B = 0;
for (int i = 0; i <= n; i++) {
    B += bal[i];
    if (B == n) {
      if ((pref[n] + i) % 2 == 0) {
        res.push_back(i);
      }
    }
  }
  if (res.empty()) {
    cout << -1 << '\n';
  } else {
    int sz = (int) res.size();
    for (int i = 0; i < sz; i++) {
      if (i > 0) {
cout << " ";
      }
      cout << res[i];
    }
    cout << '\n';
  }
  return 0;
}