Let's call an array good if there is an element in the array that equals to the sum of all other elements. For example, the array $a=[1, 3, 3, 7]$ is good because there is the element $a_4=7$ which equals to the sum $1 + 3 + 3$.

You are given an array $a$ consisting of $n$ integers. Your task is to print all indices $j$ of this array such that after removing the $j$-th element from the array it will be good (let's call such indices nice).

For example, if $a=[8, 3, 5, 2]$, the nice indices are $1$ and $4$:   if you remove $a_1$, the array will look like $[3, 5, 2]$ and it is good;  if you remove $a_4$, the array will look like $[8, 3, 5]$ and it is good. 

You have to consider all removals independently, i. e. remove the element, check if the resulting array is good, and return the element into the array.


-----Input-----

The first line of the input contains one integer $n$ ($2 \le n \le 2 \cdot 10^5$) — the number of elements in the array $a$.

The second line of the input contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^6$) — elements of the array $a$.


-----Output-----

In the first line print one integer $k$ — the number of indices $j$ of the array $a$ such that after removing the $j$-th element from the array it will be good (i.e. print the number of the nice indices).

In the second line print $k$ distinct integers $j_1, j_2, \dots, j_k$ in any order — nice indices of the array $a$.

If there are no such indices in the array $a$, just print $0$ in the first line and leave the second line empty or do not print it at all.


-----Examples-----
Input
5
2 5 1 2 2

Output
3
4 1 5
Input
4
8 3 5 2

Output
2
1 4 

Input
5
2 1 2 4 3

Output
0




-----Note-----

In the first example you can remove any element with the value $2$ so the array will look like $[5, 1, 2, 2]$. The sum of this array is $10$ and there is an element equals to the sum of remaining elements ($5 = 1 + 2 + 2$).

In the second example you can remove $8$ so the array will look like $[3, 5, 2]$. The sum of this array is $10$ and there is an element equals to the sum of remaining elements ($5 = 3 + 2$). You can also remove $2$ so the array will look like $[8, 3, 5]$. The sum of this array is $16$ and there is an element equals to the sum of remaining elements ($8 = 3 + 5$).

In the third example you cannot make the given array good by removing exactly one element.

Difficulty: EASY

Starter code:

Solutions:
x = int(input())
ls = [int(i) for i in input().split()]
v = sorted(ls)
arr = []
mx1 = v[len(v) - 1]
mx2 = v[len(v) - 2]
sm = sum(ls)
for i in range(len(ls)):
	if ls[i] == mx1:
		if sm - ls[i] - mx2 == mx2:
			arr.append(i + 1)
	elif sm - ls[i] - mx1 == mx1:
		arr.append(i + 1)
print(len(arr))
for i in range(len(arr)):
	print(arr[i], end=' ')


n = int(input())
res = []
a = input().split()
for i in range(n):
	a[i] = int(a[i])
asor = sorted(a)
run = True
su = sum(a)
m = max(a)
if run:
	for i in range(n):
		if a[i] == m:
			if su - a[i] - asor[-2] == asor[-2]:
				res.append(i + 1)
		elif su - a[i] - asor[-1] == asor[-1]:
			res.append(i + 1)
if len(res) > 0:
	print(len(res))
	for r in res:
		print(r, end=' ')
else:
	print(0)


import sys
input = sys.stdin.readline
from math import ceil, floor, factorial

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0):
	hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(1000000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
n = int(input())
a = int_array()
ans = []
s = sum(a)
for i in range(n):
	a[i] = (a[i], i)
a.sort()
for i in range(n - 1, -1, -1):
	k = s - a[i][0]
	if i == n - 1:
		k -= a[n - 2][0]
		if k == a[n - 2][0]:
			ans.append(a[i][1] + 1)
	else:
		k -= a[-1][0]
		if k == a[-1][0]:
			ans.append(a[i][1] + 1)
print(len(ans))
print(*ans)


import math, sys
from sys import stdin, stdout
from collections import Counter, defaultdict, deque
input = stdin.readline
I = lambda : int(input())
li = lambda : list(map(int, input().split()))

def case():
	n = I()
	a = li()
	ans = []
	if n < 3:
		print(0)
		exit()
	for i in range(n):
		ans.append([a[i], i])
	ans.sort(reverse=True)
	pink = []
	s = sum(a)
	for i in range(n):
		c = s
		if i == 0:
			c -= ans[i][0]
			if ans[1][0] * 2 == c:
				pink.append(ans[0][1] + 1)
		else:
			c -= ans[i][0]
			if ans[0][0] * 2 == c:
				pink.append(ans[i][1] + 1)
	print(len(pink))
	print(*pink)
for _ in range(1):
	case()


from collections import Counter, defaultdict, deque
from math import factorial as fact
n = int(input())
arr = [int(x) for x in input().split()]
c = defaultdict(int)
fmax = 0
smax = 0
s = 0
for el in arr:
	c[el] += 1
	s += el
	if el > fmax:
		smax = fmax
		fmax = el
	elif el > smax:
		smax = el
p1 = 0
p2 = 0
if s - 2 * fmax == fmax:
	if c[fmax] >= 2:
		p1 = s - 2 * fmax
else:
	p1 = s - 2 * fmax
if (s - fmax) % 2 == 0:
	if (s - fmax) // 2 == fmax:
		if c[fmax] >= 2:
			p2 = fmax
	elif c[(s - fmax) // 2] >= 1:
		p2 = fmax
ans = []
for i in range(n):
	if arr[i] == p1 or arr[i] == p2:
		ans.append(i + 1)
print(len(ans))
print(*ans)


n = int(input())
li = list(map(int, input().split()))
li2 = []
if n == 2:
	print(0)
else:
	dic = {}
	for i in range(0, n):
		if li[i] in dic.keys():
			dic[li[i]].append(i + 1)
		else:
			dic[li[i]] = [i + 1]
	p = sum(li)
	li.sort()
	for i in range(n - 1):
		if 2 * li[n - 1] == p - li[i]:
			li2.append(li[i])
	if 2 * li[n - 2] == p - li[n - 1]:
		li2.append(li[n - 1])
	print(len(li2))
	li2 = list(set(li2))
	ans = []
	for ele in li2:
		ans += dic[ele]
	print(' '.join([str(ele) for ele in ans]))


from collections import Counter
_ = input()
a = list(map(int, input().split()))
c = Counter(a)
s = sum(a)
r = []
for (i, e) in enumerate(a, 1):
	if (s - e) % 2 == 0 and (s - e) / 2 in c and ((s - e) / 2 != e or c[e] > 1):
		r.append(i)
print(len(r))
if len(r) != 0:
	print(*r)


n = int(input())
a1 = [int(i) for i in input().split()]
a = []
sum_ = 0
for i in range(n):
	a.append((a1[i], i))
	sum_ += a1[i]
a.sort()
index = []
for i in range(n):
	if i == n - 1:
		if a[n - 2][0] == sum_ - a[i][0] - a[n - 2][0]:
			index.append(a[i][1] + 1)
	elif a[n - 1][0] == sum_ - a[i][0] - a[n - 1][0]:
		index.append(a[i][1] + 1)
print(len(index))
if len(index) > 0:
	print(*index)


n = int(input())
a = sorted(((value, i) for (i, value) in enumerate(map(int, input().split()))), reverse=True)
all_sum = sum((value for (value, _) in a))
results = []
for i in range(n):
	index = 0 if i > 0 else 1
	if all_sum - a[i][0] == 2 * a[index][0]:
		results.append(a[i][1] + 1)
print(len(results))
if results:
	print(*results, sep=' ')


n = int(input())
h = list(map(int, input().split()))

def findall(lis, i):
	output = []
	for r in range(len(lis)):
		if lis[r] == i:
			output.append(r + 1)
	return output
maximum = max(h)
tichu = -2 * maximum + sum(h)
output = findall(h, tichu)
if h.index(maximum) + 1 in output:
	output.remove(h.index(maximum) + 1)
hi = list(h)
hi.remove(maximum)
if 2 * max(hi) == sum(hi):
	output.append(h.index(maximum) + 1)
if output == []:
	print(0)
else:
	print(len(output))
	print(' '.join((str(e) for e in output)))


n = int(input())
a = [int(i) for i in input().split()]
b = sorted(a)
s = sum(b[:-1])
f = s - b[-1]
r = set()
if f > 0 and (not (b.count(f) == 1 and b[-1] == f)):
	for i in range(n):
		if a[i] == f:
			r.add(i + 1)
if sum(b[:-2]) == b[-2]:
	for i in range(n):
		if a[i] == b[-1]:
			r.add(i + 1)
print(len(r))
r = list(r)
print(' '.join((str(i) for i in r)))


import collections, atexit, math, sys, bisect
sys.setrecursionlimit(1000000)

def getIntList():
	return list(map(int, input().split()))
try:
	import numpy

	def dprint(*args, **kwargs):
		print(*args, file=sys.stderr)
	dprint('debug mode')
except Exception:

	def dprint(*args, **kwargs):
		pass
inId = 0
outId = 0
if inId > 0:
	dprint('use input', inId)
	sys.stdin = open('input' + str(inId) + '.txt', 'r')
if outId > 0:
	dprint('use output', outId)
	sys.stdout = open('stdout' + str(outId) + '.txt', 'w')
	atexit.register(lambda : sys.stdout.close())
(N,) = getIntList()
za = getIntList()
ss = sum(za)
cc = collections.Counter(za)
re = []
for i in range(N):
	if (ss - za[i]) % 2 == 1:
		continue
	t = (ss - za[i]) // 2
	g = 1
	if t == za[i]:
		g += 1
	if cc[t] >= g:
		re.append(str(i + 1))
print(len(re))
print(' '.join(re))


from collections import *
n = int(input())
a = [*map(int, input().split())]
s = sum(a)
d = defaultdict(set)
b = [*enumerate(a, 1)]
for (i, x) in b:
	d[x].add(i)
r = set()
for (i, x) in b:
	r |= d[s - 2 * x] - {i}
print(len(r))
print(*r)


from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
mp = defaultdict(list)
addition = sum(a)
ans = []
for i in range(n):
	mp[a[i]].append(i)
index = 0
for i in a:
	temp = addition
	temp -= i
	if temp % 2 == 1:
		index += 1
		continue
	temp //= 2
	if temp in mp and len(mp[temp]) > 1:
		ans.append(index + 1)
	if i in mp and len(mp[temp]) == 1:
		if mp[temp][0] != index:
			ans.append(index + 1)
	index += 1
print(len(ans))
if len(ans) == 0:
	return
ans = list(map(str, ans))
print(' '.join(ans))


n = int(input())
rawa = list(map(int, input().split()))
a = sorted([(rawa[i], i) for i in range(n)])
suma = sum(rawa) - a[-1][0]
bi = []
for i in range(n):
	if i == n - 1:
		if suma - a[-2][0] == a[-2][0]:
			bi.append(a[i][1])
	elif suma - a[i][0] == a[-1][0]:
		bi.append(a[i][1])
print(len(bi))
print(' '.join([str(x + 1) for x in bi]))


n = input()
a = list(map(int, input().split()))
s = sum(a)
b = sorted(a)[-2:]
k = []
c = 0
for d in a:
	c = c + 1
	if s - d == 2 * b[1] and (b[1] != d or b[0] == d) or (s - d == 2 * b[0] and b[0] != d):
		k.append(c)
print(len(k))
print(*k)


from collections import *
input()
a = [*map(int, input().split())]
c = Counter(a)
s = sum(a)
r = []
for (i, x) in enumerate(a, 1):
	if c[(s - x) / 2] > (s == 3 * x):
		r += [str(i)]
print(len(r))
print(' '.join(r))


n = int(input())
(a, ans, b) = ([int(s) for s in input().split()], [], [])
b = sorted(a)
k = 0
(sum, max1, max2) = (0, b[n - 1], -1)
for i in range(n - 1, -1, -1):
	if max1 == b[i]:
		k += 1
	if max2 < b[i] and b[i] != max1:
		max2 = b[i]
	sum += b[i]
sum -= max1
if max2 == -1:
	max2 = max1
for i in range(n):
	if a[i] != max1:
		if sum - a[i] == max1:
			ans.append(i + 1)
	elif max2 != -1:
		if sum - max2 == max2 or (k > 1 and sum - a[i] == max1):
			ans.append(i + 1)
print(len(ans))
print(*ans)


from os import path
import sys, time
from math import ceil, floor, gcd, log, log2, factorial
from collections import defaultdict, Counter, deque
from itertools import permutations
maxx = float('inf')
I = lambda : int(sys.stdin.buffer.readline())
tup = lambda : map(int, sys.stdin.buffer.readline().split())
lint = lambda : [int(x) for x in sys.stdin.buffer.readline().split()]
S = lambda : sys.stdin.readline().replace('\n', '').strip()

def grid(r, c):
	return [lint() for i in range(r)]
stpr = lambda x: sys.stdout.write(f'{x}' + '\n')
star = lambda x: print(' '.join(map(str, x)))
localsys = 0
start_time = time.time()
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
n = I()
ls = lint()
s = sum(ls)
d = defaultdict(int)
for i in ls:
	d[i] += 1
(ans, lis) = ([], sorted(ls))
for i in range(n):
	x = s - ls[i]
	if x % 2 == 0:
		x //= 2
		if x == ls[i] and d[x] > 1:
			ans.append(i + 1)
		elif x != ls[i] and d[x] > 0:
			ans.append(i + 1)
print(len(ans))
print(*ans)
if localsys:
	print('\n\nTime Elased :', time.time() - start_time, 'seconds')


(n, a) = (int(input()), [*map(int, input().split())])
(s, b) = (sum(a), sorted(a)[::-1])
k = [_ + 1 for _ in range(n) if s - a[_] == 2 * b[a[_] == b[0]]]
print(len(k), *k)


n = int(input())
l = list(map(int, input().split()))
s = sum(l)
res = []
x = s // 2
y = s - x
dic = {}
for i in l:
	if i in dic:
		dic[i] = dic[i] + 1
	else:
		dic[i] = 1
c = 0
for i in range(len(l)):
	z = s - l[i]
	dic[l[i]] = dic[l[i]] - 1
	if z % 2 == 0 and z // 2 in dic and (dic[z // 2] >= 1):
		c = c + 1
		res.append(i + 1)
	dic[l[i]] = dic[l[i]] + 1
if len(res) == 0:
	print(0)
else:
	print(c)
	for i in res:
		print(i, end=' ')


import sys
import collections
inp = sys.stdin
n = int(inp.readline())
a = list(map(int, inp.readline().split()))
o = []
s = collections.Counter()
for aa in a:
	s[aa] += 1
sm = sum(a)
for i in range(0, n):
	sm = sm - a[i]
	s[a[i]] -= 1
	if sm % 2 == 0 and sm / 2 in s and (s[sm / 2] > 0):
		o.append(i + 1)
	s[a[i]] += 1
	sm += a[i]
print(len(o))
print(' '.join(map(str, o)))


def is_nice(numbers, banned, max_sum):
	num_sum = max_sum - banned
	if num_sum % 2 != 0:
		return False
	nice_num = num_sum // 2
	if nice_num not in numbers:
		return False
	if nice_num == banned and numbers[nice_num] == 1:
		return False
	return True

def solve(lst):
	memo = {}
	numbers = {}
	max_sum = 0
	for n in lst:
		if n not in numbers:
			numbers[n] = 1
		else:
			numbers[n] += 1
		max_sum += n
	indices = []
	for i in range(len(lst)):
		if lst[i] not in memo:
			memo[lst[i]] = is_nice(numbers, lst[i], max_sum)
		if memo[lst[i]]:
			indices.append(i)
	return (len(indices), indices)
n = int(input())
lst = [int(x) for x in input().split()]
(size, indices) = solve(lst)
print(size)
for i in indices:
	print(i + 1, end=' ')


n = int(input())
aa = [int(x) for x in input().split()]
s = sum(aa)
a = []
for i in range(0, n):
	a.append([aa[i], i])
a = sorted(a, key=lambda s: s[0])
c = 0
b = []
for i in range(0, n):
	summe = s - a[i][0]
	tmp = a[i]
	if i != n - 1:
		x = a[-1][0]
	else:
		x = a[-2][0]
	if x == summe - x:
		b.append(tmp[1])
		c += 1
print(c)
for e in b:
	print(e + 1, end=' ')


def main():
	n = int(input())
	a = list(map(int, input().split(' ')))
	arr = a[:]
	max1 = max(arr)
	arr.remove(max1)
	max2 = max(arr)
	sums = sum(a)
	ans = 0
	val = []
	for i in range(n):
		if a[i] == max1:
			if sums - max1 - max2 == max2:
				ans = ans + 1
				val.append(i + 1)
		elif sums - a[i] - max1 == max1:
			ans = ans + 1
			val.append(i + 1)
	print(ans)
	for i in range(len(val)):
		print(val[i], end=' ')
main()


n = int(input())
a = [int(x) for x in input().split()]
s = sum(a)
q = sorted(a)
h1 = q[-1]
h2 = q[-2]
ans = []
for i in range(n):
	d = a[i]
	if a[i] == h1:
		h = h2
	else:
		h = h1
	if s - a[i] - h == h:
		ans.append(i + 1)
print(len(ans))
print(*ans)


import itertools
n = int(input())
a = []
count = 0
a = [int(x) for x in input().split()]
d = {}
sid = 0
sum = 0
index = []
dic = {}
for i in range(n):
	d[i + 1] = a[i]
a.sort(reverse=True)
dd = sorted(d, key=d.get, reverse=True)
dic = dict(zip(dd, a))
for i in dic:
	sum += dic[i]
for i in dic:
	sid += 1
	if sid == 1:
		sta = i
	if sid == 2:
		nex = i
	if sid != 1:
		summ = sum - dic[sta]
		summ -= dic[i]
		if dic[sta] == summ:
			count += 1
			index.append(i)
if dic[nex] == sum - dic[nex] - dic[sta]:
	count += 1
	index.append(sta)
print(count)
if count != 0:
	for i in index:
		print(i, end=' ')


n = int(input())
a = list(map(int, input().split()))
sort_a = sorted(a)
max_fi = sort_a[-1]
max_se = sort_a[-2]
sum_a = sum(a)
ans = 0
ans_a = []
for i in range(0, n):
	if a[i] != max_fi:
		if sum_a - max_fi - a[i] == max_fi:
			ans += 1
			ans_a.append(i + 1)
	elif sum_a - max_se - a[i] == max_se:
		ans += 1
		ans_a.append(i + 1)
print(ans)
if ans > 0:
	print(' '.join([str(n) for n in ans_a]))


def main():
	n = int(input())
	a = list(map(int, input().split(' ')))
	sorted_a_enum = sorted(enumerate(a), key=lambda x: x[1], reverse=True)
	a_sum = sum(a)
	j_list = []
	for (ii, a_elem) in enumerate(sorted_a_enum):
		(i, ai) = a_elem
		greatest_val_in_a = sorted_a_enum[0][1] if ii > 0 else sorted_a_enum[1][1]
		if a_sum - ai == greatest_val_in_a * 2:
			j_list.append(i + 1)
	print(len(j_list))
	print(' '.join(list(map(str, j_list))))
main()


n = int(input())
l = list(map(int, input().split()))
r = []
s = 0
for i in range(n):
	s += l[i]
m = {}
for i in range(1000001):
	m[i] = 0
for i in range(n):
	m[l[i]] += 1
for i in range(n):
	cur = s - l[i]
	if cur // 2 > 1000000.0:
		continue
	if cur % 2 == 0:
		if cur // 2 == l[i]:
			if m[cur // 2] >= 2:
				r.append(i)
		elif m[cur // 2] > 0:
			r.append(i)
print(len(r))
for i in r:
	print(i + 1, end=' ')


n = int(input())
a = list(map(int, input().strip().split()))
summa = sum(a)
p = [0] * 2000006
for x in a:
	p[x] += 1
res = []
n = len(a)
for i in range(0, n):
	n_summa = summa - a[i]
	if n_summa % 2 == 1:
		continue
	r = n_summa // 2
	if r > 2000000 or r < 0:
		continue
	p[a[i]] -= 1
	if p[r] > 0:
		res.append(i)
	p[a[i]] += 1
print(len(res))
for x in res:
	print(x + 1, end=' ')


n = int(input())
lis = list(map(int, input().split()))
lis2 = []
for i in range(n):
	lis2.append(lis[i])
lis2.sort()
sum = 0
for i in range(n):
	sum = sum + lis[i]
temp = sum
c = 0
lis1 = []
for i in range(n):
	if lis[i] != lis2[n - 1]:
		temp = temp - lis[i] - lis2[n - 1]
		if temp == lis2[n - 1]:
			c = c + 1
			lis1.append(i + 1)
	else:
		temp = temp - lis[i] - lis2[n - 2]
		if temp == lis2[n - 2]:
			c = c + 1
			lis1.append(i + 1)
	temp = sum
print(c)
for i in range(c):
	print(lis1[i], end=' ')


n = int(input())
a = list(map(int, input().split(' ')))
rev_map = {}
for (i, ai) in enumerate(a):
	if ai in rev_map:
		rev_map[ai].append(i)
	else:
		rev_map[ai] = [i]
indices = set()
total = sum(a)
for ai in rev_map:
	subtotal = total - ai
	if subtotal % 2 == 0 and subtotal // 2 in rev_map and (not ai == subtotal // 2 or len(rev_map[subtotal // 2]) > 1):
		for index in rev_map[ai]:
			indices.add(index + 1)
print(len(indices))
print(*list(indices))


I = lambda : map(int, input().split())
n = int(input())
a = list(I())
c = []
maxx = 0
smax = 0
for i in range(n):
	if maxx < a[i]:
		smax = maxx
		maxx = a[i]
	elif smax < a[i]:
		smax = a[i]
s = sum(a)
for i in range(n):
	if maxx != a[i]:
		if 2 * maxx == s - a[i]:
			c.append(i + 1)
	elif s - a[i] == 2 * smax:
		c.append(i + 1)
print(len(c))
print(*c)


import math
import bisect
import itertools
import sys
mod = 10 ** 9 + 7

def mindiff(a):
	b = a[:]
	b.sort()
	m = 10000000000
	for i in range(len(b) - 1):
		if b[i + 1] - b[i] < m:
			m = b[i + 1] - b[i]
	return m

def lcm(a, b):
	return a * b // math.gcd(a, b)

def merge(a, b):
	i = 0
	j = 0
	c = 0
	ans = []
	while i < len(a) and j < len(b):
		if a[i] < b[j]:
			ans.append(a[i])
			i += 1
		else:
			ans.append(b[j])
			c += len(a) - i
			j += 1
	ans += a[i:]
	ans += b[j:]
	return (ans, c)

def mergesort(a):
	if len(a) == 1:
		return (a, 0)
	mid = len(a) // 2
	(left, left_inversion) = mergesort(a[:mid])
	(right, right_inversion) = mergesort(a[mid:])
	(m, c) = merge(left, right)
	c += left_inversion + right_inversion
	return (m, c)

def is_prime(num):
	if num == 2:
		return True
	if num == 3:
		return True
	if num % 2 == 0:
		return False
	if num % 3 == 0:
		return False
	t = 5
	a = 2
	while t <= int(math.sqrt(num)):
		if num % t == 0:
			return False
		t += a
		a = 6 - a
	return True

def ceil(a, b):
	if a % b == 0:
		return a // b
	else:
		return a // b + 1

def binsearch(arr, b, low, high):
	if low == high:
		return low
	if arr[math.ceil((low + high) / 2)] < b:
		return binsearch(arr, b, low, math.ceil((low + high) / 2) - 1)
	else:
		return binsearch(arr, b, math.ceil((low + high) / 2), high)

def ncr1(n, r):
	s = 1
	for i in range(min(n - r, r)):
		s *= n - i
		s %= mod
		s *= pow(i + 1, mod - 2, mod)
		s %= mod
	return s

def calc(n, m, r):
	s = 0
	for i in range(0, r + 1, 2):
		s += ncr1(n, i) * ncr1(m, i)
		s %= mod
	return s
n = int(input())
a = list(map(int, input().split()))
s = sum(a)
b = []
count = 0
c = []
for i in range(n):
	b.append(s - a[i])
ma = min(a)
sm = min(a)
for i in range(n):
	if ma < a[i]:
		sm = ma
		ma = a[i]
	elif sm < a[i]:
		sm = a[i]
for i in range(n):
	if a[i] == ma:
		if b[i] / 2 == sm:
			count += 1
			c.append(i + 1)
	elif b[i] / 2 == ma:
		count += 1
		c.append(i + 1)
if count == 0:
	print(count)
	return
print(count)
print(*c)


n = int(input())
l = list(map(int, input().split()))
l1 = [0] * 10000000
s = 0
ans = 0
l2 = []
for i in range(n):
	l1[l[i]] += 1
	s += l[i]
for i in range(n):
	l1[l[i]] -= 1
	s -= l[i]
	if s % 2 == 0 and s // 2 <= 1000000:
		if l1[s // 2] > 0:
			ans += 1
			l2.append(i + 1)
	l1[l[i]] += 1
	s += l[i]
print(ans)
for i in range(ans):
	print(l2[i], end=' ')
print()


n = int(input())
A = list(map(int, input().split()))
summa = 0
d = dict()
ans = set()
for i in range(len(A)):
	elem = A[i]
	summa += elem
	try:
		d[elem].add(i)
	except:
		d[elem] = set()
		d[elem].add(i)
for i in range(len(A)):
	elem = A[i]
	if summa - elem <= elem:
		continue
	x = summa - elem * 2
	if x in d.keys():
		s = d[x]
		for j in s:
			if j != i:
				ans.add(j)
print(len(ans))
if len(ans) != 0:
	for i in ans:
		print(i + 1, end=' ')


n = int(input())
a = list(map(int, input().split()))
path = []
sm = sum(a)
b = dict()
for i in range(n):
	b[i + 1] = a[i]
a = list(b.items())
a.sort(key=lambda x: (x[1], x[0]))
for i in range(n):
	if i == n - 1:
		if sm - a[i][1] - a[i - 1][1] == a[i - 1][1]:
			path.append(a[i][0])
	elif a[-1][1] == sm - a[-1][1] - a[i][1]:
		path.append(a[i][0])
print(len(path))
print(*path)


n = int(input())
a = list(map(int, input().split()))
d = {}
for item in a:
	if d.get(item):
		d[item] += 1
	else:
		d[item] = 1
s = sum(a)
res = []
for i in range(n):
	d[a[i]] -= 1
	if d.get((s - a[i]) / 2):
		if d.get((s - a[i]) / 2) >= 1:
			res.append(i + 1)
	d[a[i]] += 1
print(len(res))
print(*res)


n = int(input())
(a, k) = (list(map(int, input().split())), [])
(sum, max1) = (sum(a), max(a))
a2 = a.copy()
a2.remove(max1)
max2 = max(a2)
del a2
if n > 2:
	for i in range(n):
		if sum - a[i] == 2 * max1 and a[i] != max1:
			k.append(i + 1)
		elif sum - a[i] == 2 * max1 and max1 == max2:
			k.append(i + 1)
	if sum - max1 == 2 * max2 and a.index(max1) + 1 not in k:
		k.append(a.index(max1) + 1)
	print(len(k))
	for i in k:
		print(i, end=' ')
else:
	print('0')


import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
count = {}
sum = 0
for i in range(n):
	if a[i] not in count.keys():
		count[a[i]] = 0
	count[a[i]] += 1
	sum += a[i]
ans = []
for i in range(n):
	sub = sum - a[i]
	if sub % 2 == 1:
		continue
	sub = int(sub / 2)
	if sub in count.keys() and sub == a[i]:
		if count[sub] > 1:
			ans.append(str(i + 1))
	elif sub in count.keys() and count[sub] >= 1:
		ans.append(str(i + 1))
print(len(ans))
print(' '.join(ans))


n = int(input())
l = list(map(int, input().split()))
maa = max(l)
m = 0
if l.count(maa) > 1:
	m = maa
else:
	for i in l:
		if i > m and i != maa:
			m = i
s = sum(l)
f = 0
ll = []
for i in range(len(l)):
	a = l[i]
	if a == maa:
		b = m
	else:
		b = maa
	if s - a - b == b:
		f = 1
		ll.append(i + 1)
if f == 0:
	print(0)
else:
	print(len(ll))
	print(*ll)


n = int(input())
a = input().split()
b = 0
for i in range(n):
	a[i] = [int(a[i]), i]
	b += a[i][0]
a.sort()
ls = []
for i in range(n):
	if i != n - 1:
		if b - a[i][0] - a[n - 1][0] == a[n - 1][0]:
			ls.append(a[i][1] + 1)
	elif b - a[i][0] - a[n - 2][0] == a[n - 2][0]:
		ls.append(a[i][1] + 1)
print(len(ls))
print(*ls)


n = int(input())
a = [int(i) for i in input().split()]
s = sum(a) / 2
b = [[a[i - 1], i] for i in range(1, n + 1)]
b.sort()
for i in range(1, n):
	if b[i - 1][0] <= s <= b[i][0]:
		k = i - 1
		break
else:
	k = n - 1
ans = []
num = 0
for i in range(n):
	while k >= 0 and b[k][0] > s - b[i][0] / 2:
		k -= 1
	if k == -1:
		break
	if b[k][0] == s - b[i][0] / 2:
		if k == i:
			if b[k - 1][0] == b[k][0]:
				ans.append(b[i][1])
				num += 1
		else:
			ans.append(b[i][1])
			num += 1
print(num)
print(' '.join([str(r) for r in ans]))


def main():
	N = int(input())
	A = [int(i) for i in input().split()]
	S = sum(A)
	from collections import Counter
	c = Counter(A)
	ans = []
	for i in range(N):
		v = S - A[i]
		if v % 2 == 1:
			continue
		v //= 2
		if v != A[i] and c[v] > 0 or c[v] > 1:
			ans.append(i + 1)
	print(len(ans))
	print(*ans)
main()


n = int(input())
a = list(map(int, input().split()))
s = sum(a)
f = {i: 0 for i in a}
for i in a:
	f[i] += 1
nice = []
for i in range(n):
	rem = s - a[i]
	if rem % 2 == 0:
		need = rem // 2
		if need in f:
			x = f[need]
			if rem // 2 == a[i] and x > 1 or (x > 0 and rem // 2 != a[i]):
				nice.append(i + 1)
print(len(nice))
print(*nice)


(n, a, x, y, k) = (int(input()), list(map(int, input().split())), int(), int(), list())
s = sum(a)
for _ in range(n):
	if x <= a[_]:
		(x, y) = (a[_], x)
	elif y < a[_]:
		y = a[_]
for _ in range(n):
	if a[_] == x:
		if s - a[_] == 2 * y:
			k.append(_ + 1)
	elif s - a[_] == 2 * x:
		k.append(_ + 1)
print(len(k), *k)


from collections import Counter as C
n = int(input())
l = [*map(int, input().split())]
c = C(l)
s = sum(l)
res = []
for (i, e) in enumerate(l):
	if c.get((s - e) / 2, 0) > int((s - e) / 2 == e):
		res.append(str(i + 1))
print(len(res))
print(' '.join(res))


def inint():
	return int(input())

def inlist():
	return list(map(int, input().split()))

def main():
	n = inint()
	a = inlist()
	sa = [(a[i], i) for i in range(n)]
	sa.sort()
	sm = sum(a)
	sm -= sa[-1][0]
	val = sa[-1][0]
	sol = []
	for i in range(n - 1):
		if sm - sa[i][0] == val:
			sol.append(sa[i][1] + 1)
	sm -= sa[-2][0]
	if sm == sa[-2][0]:
		sol.append(sa[-1][1] + 1)
	print(len(sol))
	print(*sol)
main()


n = int(input())
l = list(map(int, input().split()))
s = sum(l)
(max1, max2) = sorted(l, reverse=True)[:2]
pretty_indexes = []
for (i, ll) in enumerate(l, start=1):
	if s - ll == 2 * (max1 if ll != max1 else max2):
		pretty_indexes.append(str(i))
print(len(pretty_indexes))
print(' '.join(pretty_indexes))


n = int(input())
l = [int(i) for i in input().split()]
s = sum(l)
res = []
from collections import Counter
c = Counter(l)
for i in range(n):
	curr = s - l[i]
	if c[curr / 2]:
		if l[i] * 3 == s:
			if c[l[i]] > 1:
				res.append(i + 1)
		else:
			res.append(i + 1)
print(len(res))
print(*res)


n = int(input())
a = [int(e) for e in input().split()]
ans = []
sm = 0
st = dict()
for i in a:
	st[i * 2] = st.get(i * 2, 0) + 1
	sm += i
for (i, j) in enumerate(a):
	t = sm - j
	if t == 2 * j and st.get(t, 0) <= 1:
		continue
	if st.get(t, 0) > 0:
		ans.append(i + 1)
print(len(ans))
print(' '.join((str(e) for e in ans)))


from collections import *
n = int(input())
l = list(map(int, input().split()))
s = set(l)
dic = Counter(l)
x = sum(l)
arr = []
for i in range(n):
	if (x - l[i]) % 2 == 0:
		if (x - l[i]) // 2 in s:
			if (x - l[i]) // 2 == l[i] and dic[l[i]] > 1:
				arr.append(i + 1)
			elif (x - l[i]) // 2 != l[i]:
				arr.append(i + 1)
print(len(arr))
print(*arr)


from collections import defaultdict, Counter
n = int(input())
a = list(map(int, input().split()))
C = defaultdict(int, Counter(a))
s = sum(a)
ans = 0
ans_l = list()
for i in range(n):
	el = a[i]
	C[el] -= 1
	if C[(s - el) / 2]:
		ans += 1
		ans_l.append(i + 1)
	C[el] += 1
print(ans)
print(' '.join(map(str, ans_l)))


n = int(input())
x = [int(n) for n in input().split()]
a = {}
s = 0
for i in range(n):
	s += x[i]
	try:
		a[x[i]].append(i + 1)
	except:
		a[x[i]] = []
		a[x[i]].append(i + 1)
c = 0
m1 = max(x)
if x.count(m1) >= 2:
	m2 = m1
else:
	m2 = 0
	for i in x:
		if i != m1:
			m2 = max(m2, i)
ans = []
for i in a:
	if i == m1:
		if s - m1 == 2 * m2:
			for j in a[i]:
				c += 1
				ans.append(j)
	elif s - i == 2 * m1:
		for j in a[i]:
			c += 1
			ans.append(j)
print(c)
print(*ans)


import sys
import math
n = int(input())
a = list(map(int, input().split()))
b = []
sumi = sum(a)
for i in range(n):
	b.append([a[i], i + 1])
b.sort(reverse=True)
res = []
for i in range(n):
	temp = sumi
	if i == 0:
		temp = temp - b[0][0]
		if b[1][0] == temp - b[1][0]:
			res.append(b[0][1])
	else:
		temp = temp - b[i][0]
		if b[0][0] == temp - b[0][0]:
			res.append(b[i][1])
print(len(res))
print(*res)


n = int(input())
pr = list(map(int, input().split()))
total = 0
for i in range(n):
	total += pr[i]
ans = []
g = max(pr)
pr[pr.index(g)] = 0
m = max(pr)
pr[pr.index(0)] = g
for i in range(n):
	total -= pr[i]
	temp = pr[i]
	pr[i] = 0
	if g != temp:
		if g == total - g:
			ans.append(i + 1)
	elif m == total - m:
		ans.append(i + 1)
	pr[i] = temp
	total += pr[i]
print(len(ans))
print(*ans)


input()
a = [*map(int, input().split())]
s = sum(a)
h = sorted(a)[-2:]
r = [i for (i, x) in enumerate(a, 1) if s - x == 2 * h[x != h[1]]]
print(len(r))
print(*r)


n = int(input())
l = str(input())
l = l.split(' ')
l = [int(g) for g in l if g != '' and g != ' ']
r = []
s = 0
y = l.copy()
y.sort()
a = y[n - 1]
b = y[n - 2]
for j in range(n):
	s = s + y[j]
for i in range(n):
	if l[i] != a:
		if s - l[i] == 2 * a:
			r.append(i + 1)
	elif s - l[i] == 2 * b:
		r.append(i + 1)
print(len(r))
for i in range(len(r)):
	print(r[i], end=' ')


MAX = 1000002
n = int(input())
a = list(map(int, input().split()))
s = sum(a)
cnt = [0] * MAX
for i in a:
	cnt[i] += 1
ans = []
for i in range(n):
	tmp = s - a[i]
	cnt[a[i]] -= 1
	if (tmp % 2 == 0 and tmp / 2 <= MAX and cnt[tmp // 2]) > 0:
		ans.append(i + 1)
	cnt[a[i]] += 1
print(len(ans))
print(*ans)


def isGood(s, d):
	try:
		m = d[s // 2]
		return m > 0
	except:
		return False
n = int(input())
a = list(map(int, input().split()))
d = dict()
niceIndices = []
s = sum(a)
for i in range(n):
	try:
		d[a[i]] += 1
	except:
		d[a[i]] = 1
for i in range(n):
	sumOfRest = s - a[i]
	d[a[i]] -= 1
	if sumOfRest % 2 == 1:
		d[a[i]] += 1
		continue
	if isGood(sumOfRest, d):
		niceIndices.append(i + 1)
	d[a[i]] += 1
print(len(niceIndices))
for i in niceIndices:
	print(i, end=' ')


n = int(input())
seq = list(map(int, input().split()))
mx = max(seq)
sm = sum(seq)
nseq = [seq[i] for i in range(n)]
nseq.remove(mx)
mx2 = max(nseq)
ans = []
for i in range(n):
	s = seq[i]
	if s == mx:
		if sm - s == 2 * mx2:
			ans.append(i + 1)
	elif sm - s == 2 * mx:
		ans.append(i + 1)
print(len(ans))
print(' '.join(list(map(str, ans))))


from operator import itemgetter
n = int(input())
a = list(map(int, input().split()))
co = [0] * (max(a) + 1)
for i in range(n):
	co[a[i]] += 1
su = sum(a)
ar = []
c = 0
ma = max(a)
for i in range(n):
	if a[i] == ma:
		ind = i
		break
su2 = sum(a) - ma
for i in range(n):
	if i != ind and su2 - a[i] == ma:
		ar.append(i + 1)
		c += 1
for i in range(n):
	if a[i] == ma:
		a.pop(i)
		ind = i
		break
ma2 = max(a)
su = sum(a) - ma2
if su == ma2:
	ar.append(ind + 1)
	c += 1
print(c)
for i in range(len(ar)):
	print(ar[i], end=' ')
print()


import sys
input = sys.stdin.readline
out = sys.stdout

def main():
	n = int(input())
	a = list(map(int, input().split()))
	current = a[:]
	q_1 = max(current)
	del current[current.index(q_1)]
	q_2 = max(current)
	d = {}
	qw = sum(a)
	for i in range(n):
		if a[i] != q_1:
			d[i] = qw - a[i] - q_1
		else:
			d[i] = qw - a[i] - q_2
	answer = 0
	ans_mas = []
	for i in range(n):
		if a[i] != q_1:
			if d[i] == q_1:
				answer += 1
				ans_mas.append(i + 1)
		elif d[i] == q_2:
			answer += 1
			ans_mas.append(i + 1)
	out.write(str(answer) + '\n')
	if answer != 0:
		for k in ans_mas:
			out.write(str(k) + ' ')
main()


import math
n = int(input())
a = list(map(int, input().rstrip().split()))
d = dict()
m = []
count = 0
sum1 = sum(a)
for i in a:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
for i in range(n):
	if math.ceil((sum1 - a[i]) / 2) == math.floor((sum1 - a[i]) / 2) and (sum1 - a[i]) // 2 in d:
		if (sum1 - a[i]) // 2 == a[i] and d[a[i]] == 1:
			pass
		else:
			m.append(i + 1)
			count += 1
print(count)
print(' '.join((str(e) for e in m)))


import math
import collections
import bisect
import heapq
import time
import itertools
import sys
N = int(input())
A = [int(x) for x in input().split()]
total = sum(A)
vals = collections.Counter(A)
mxVal = max(A)
ans = []
if vals[mxVal] > 1:
	for (i, v) in enumerate(A):
		rest = total - v
		if rest - mxVal == mxVal:
			ans.append(i + 1)
else:
	for (i, v) in enumerate(A):
		rest = total - v
		if v == mxVal:
			second = max(max(A[:i] or [0]), max(A[i + 1:] or [0]))
			if rest - second == second:
				ans.append(i + 1)
		elif rest - mxVal == mxVal:
			ans.append(i + 1)
if ans:
	print(len(ans))
	print(' '.join(map(str, ans)))
else:
	print(0)


n = int(input())
a = list(map(int, input().split()))
s = sum(a)
d = dict()
for i in range(n):
	if a[i] in d:
		d[a[i]].append(i + 1)
	else:
		d[a[i]] = [i + 1]
ans = []
for k in d.keys():
	if (s - k) % 2 > 0:
		continue
	m = (s - k) // 2
	if m in d and (m != k or len(d[k]) > 1):
		ans += d[k]
print(len(ans))
print(' '.join([str(i) for i in ans]))


n = int(input())
a = [int(s) for s in input().split()]
b = []
b = list(a)
b.sort()
ids = []
r = sum(b) - 2 * b[-1]
(i, j) = (0, 0)
if r in b:
	if r == b[-1] and b[-2] != b[-1]:
		print(0)
	else:
		while i < len(a):
			if a[i] == r:
				ids.append(i + 1)
				j += 1
			i += 1
		if (sum(a) - b[-1]) // 2 == b[-2] and (sum(a) - b[-1]) % 2 == 0:
			if a.index(b[-1]) + 1 not in ids:
				ids.append(a.index(b[-1]) + 1)
				j += 1
		print(j)
		print(' '.join(map(str, ids)))
elif (sum(a) - b[-1]) // 2 == b[-2] and (sum(a) - b[-1]) % 2 == 0:
	ids.append(a.index(b[-1]))
	print(1)
	print(ids[0] + 1)
else:
	print(0)


from operator import itemgetter
n = int(input())
ai = list(map(int, input().split()))
ai2 = [[ai[i], i + 1] for i in range(n)]
ai2.sort(key=itemgetter(0))
ans = []
index = n - 1
index2 = 0
num = sum(ai)
while index2 < n and index > -1:
	temp = (num - ai2[index2][0]) / 2
	while index > -1 and temp < ai2[index][0]:
		index -= 1
	if temp == ai2[index][0]:
		if index == index2:
			if temp == ai2[index - 1][0]:
				ans += [ai2[index2][1]]
		else:
			ans += [ai2[index2][1]]
	index2 += 1
print(len(ans))
for i in ans:
	print(i, end=' ')


from collections import Counter
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def dice():
	dp = [0] * (n + 1)
	dp[1] = 1
	dp[0] = 1
	for i in range(2, n + 1):
		for j in range(1, 7):
			if i - j >= 0:
				dp[i] = (dp[i] + dp[i - j]) % (10 ** 9 + 7)
			else:
				break
import sys
import math
from collections import Counter
n = int(input())
arr = list(map(int, input().split()))
var = sum(arr)
c = Counter(arr)
cnt = 0
ans = []
for i in range(n):
	cn = var - arr[i]
	if cn % 2 == 0:
		if cn // 2 in c:
			if arr[i] != cn // 2:
				cnt += 1
				ans.append(i + 1)
			elif c[cn // 2] > 1:
				cnt += 1
				ans.append(i + 1)
print(cnt)
if cnt > 0:
	print(*ans)


n = int(input())
a = [int(x) for x in input().split()]
b = [0] * (max(a) + 1)
for i in range(n):
	b[a[i]] += 1
s = sum(a)
d = set(a)
c = []
for i in range(n):
	m = s - a[i]
	if m % 2 == 0 and m // 2 in d:
		if not (m // 2 == a[i] and b[m // 2] == 1):
			c.append(i)
if len(c) == 0:
	print(0)
else:
	print(len(c))
	for i in c:
		print(i + 1, end=' ')


n = int(input())
a = [int(i) for i in input().split()]
for i in range(n):
	a[i] = [a[i], i]
a.sort()
a.reverse()
s = sum((i for (i, _) in a))
res = []
for i in range(n):
	if i > 0:
		ind = 0
	else:
		ind = 1
	if s - a[i][0] == 2 * a[ind][0]:
		res.append(a[i][1] + 1)
print(len(res))
if len(res) != 0:
	print(*res)


from collections import Counter
n = int(input())
a = list(map(int, input().split()))
b = Counter(a)
s = sum(a)
res = []
for i in range(n):
	if (s - a[i]) % 2 == 0 and (s - a[i]) // 2 in b and ((s - a[i]) // 2 != a[i] or b[a[i]] > 1):
		res.append(i + 1)
print(len(res))
if len(res) != 0:
	print(*res)


n = int(input())
a = list(map(int, input().split()))
max1 = a[0]
q = 0
max2 = a[1]
if max1 < max2:
	(max1, max2) = (max2, max1)
	q = 1
s = 0
for i in range(n):
	s += a[i]
	if a[i] > max1:
		(max1, max2) = (a[i], max1)
		q = i
	elif a[i] > max2 and i != q:
		max2 = a[i]
count = 0
b = []
for i in range(n):
	if a[i] == max1:
		if s - a[i] - max2 == max2:
			count += 1
			b.append(i)
	elif a[i] != max1:
		if s - a[i] - max1 == max1:
			count += 1
			b.append(i)
print(count)
for i in range(len(b)):
	if b[i] != -1:
		print(b[i] + 1, end=' ')


n = int(input())
a = list(map(int, input().split()))
ans = []
su = sum(a)
dic = {}
for item in a:
	dic[item] = dic.get(item, 0) + 1
for i in range(n):
	su -= a[i]
	dic[a[i]] -= 1
	if su % 2 == 0 and dic.get(su // 2, 0) > 0:
		ans.append(i + 1)
	dic[a[i]] += 1
	su += a[i]
print(len(ans))
print(*ans)


N = int(input())
A = list(map(int, input().split()))
B = sorted(A)
S = sum(A)
r = []
for i in range(N):
	m = B[-1] if A[i] != B[-1] else B[-2]
	if S - A[i] - m == m:
		r.append(i + 1)
print(len(r))
if r:
	print(' '.join(map(str, r)))


n = int(input())
a = list(map(int, input().split()))
s = sum(a)
answer = []
maxi = max(a)
posMax = a.index(maxi)
for i in range(n):
	if a[i] == maxi and i == posMax:
		tempMax = max(a[:i] + a[i + 1:])
		if s - a[i] - tempMax == tempMax:
			answer.append(i + 1)
	elif s - a[i] - maxi == maxi:
		answer.append(i + 1)
print(len(answer))
print(*answer)


n = int(input())
m = list(map(int, input().split()))
p = sorted(m, reverse=True)
l = sum(m)
j = []
for i in range(n):
	if p[0] == m[i]:
		if 2 * p[1] == l - m[i]:
			j.append(i + 1)
	elif 2 * p[0] == l - m[i]:
		j.append(i + 1)
print(len(j))
print(*j)


n = int(input())
ans = []
a = list(map(int, input().split()))
m = 0
m2 = 0
cc = 0
im = 0
for i in range(n):
	cc += a[i]
	if a[i] > m:
		m2 = m
		m = a[i]
		im = i
	elif a[i] > m2:
		m2 = a[i]
k = cc - m - m
if cc - m - m2 == m2:
	ans.append(im + 1)
for i in range(n):
	if a[i] == k and i != im:
		ans.append(i + 1)
print(len(ans))
for i in ans:
	print(i, end=' ')


from collections import defaultdict
d = defaultdict(lambda : 0)
n = int(input())
a = [int(i) for i in input().split()]
k = 0
s = sum(a)
ans = []
for e in a:
	d[e] += 1
for i in range(n):
	t = s - a[i]
	if t % 2 == 0 and (t // 2 == a[i] and d[t // 2] > 1 or (t // 2 != a[i] and d[t // 2] >= 1)):
		k += 1
		ans.append(i + 1)
print(k)
if k:
	for e in ans:
		print(e, end=' ')


n = int(input())
a = list(map(int, input().split()))
s = sum(a)
(m1, m2) = (int(), int())
for _ in range(n):
	if m1 <= a[_]:
		(m1, m2) = (a[_], m1)
	elif m2 < a[_]:
		m2 = a[_]
ans = list()
for _ in range(n):
	if a[_] == m1 and s - a[_] == 2 * m2:
		ans.append(_ + 1)
	elif a[_] != m1 and s - a[_] == 2 * m1:
		ans.append(_ + 1)
print(len(ans), *ans)


n = int(input())
a = list(map(int, input().split()))
s = sum(a)
ans = []
(ma, se) = (0, 0)
for i in range(n):
	if ma < a[i]:
		se = ma
		ma = a[i]
	elif ma == a[i]:
		se = a[i]
	elif se < a[i]:
		se = a[i]
for i in range(n):
	s -= a[i]
	if a[i] == ma:
		if s == se * 2:
			ans.append(i + 1)
		s += a[i]
		continue
	if s == ma * 2:
		ans.append(i + 1)
	s += a[i]
print(len(ans))
print(' '.join(map(str, ans)))


n = int(input())
l = list(map(int, input().split()))
nums = set()
ans = 0
copy = l[:]
copy.sort()
sm = sum(copy)
for i in range(n - 1):
	if sm - copy[i] - copy[-1] == copy[-1]:
		nums.add(copy[i])
		ans += 1
if sm - copy[-1] - copy[-2] == copy[-2]:
	nums.add(copy[-1])
	ans += 1
print(ans)
for i in nums:
	for j in range(len(l)):
		if i == l[j]:
			print(j + 1, end=' ')


n = int(input())
a = list(map(int, input().split(' ')))
s = sum(a)
m = max(a)
ind = a.index(m)
m1 = 0
for i in range(len(a)):
	if i != ind:
		if a[i] > m1:
			m1 = a[i]
b = []
for i in range(len(a)):
	if a[i] == m:
		s = s - a[i]
		if s == 2 * m1:
			b.append(i + 1)
		s += a[i]
	else:
		s = s - a[i]
		if s == 2 * m:
			b.append(i + 1)
		s += a[i]
if len(b) == 0:
	print(0)
else:
	print(len(b))
	print(*b)


n = int(input())
l = list(map(int, input().split()))
sum = sum(l)
arr = [0] * 1000001
for i in range(n):
	arr[l[i]] += 1
ans = []
for i in range(n):
	sum = sum - l[i]
	arr[l[i]] -= 1
	if sum % 2 == 0 and sum // 2 <= 10 ** 6 and arr[sum // 2]:
		ans.append(i + 1)
	arr[l[i]] += 1
	sum = sum + l[i]
print(len(ans))
print(*ans)


n = int(input())
a = [int(i) for i in input().split()]
if n > 2:
	b = a[:]
	b.sort()
	fi = b[-1]
	se = b[-2]
	su = sum(a)
	tot = 0
	ind = []
	for i in range(len(a)):
		if a[i] != fi and su - a[i] == 2 * fi:
			tot += 1
			ind.append(i + 1)
		elif a[i] == fi:
			if su - a[i] == 2 * se:
				tot += 1
				ind.append(i + 1)
	print(tot)
	print(*ind)
else:
	print(0)
	print()


n = int(input())
ta = list(map(int, input().split()))
a = sorted(ta)
s = sum(a)
if n == 3 and len(set(a)) == 1:
	print(3)
	print(1, 2, 3)
else:
	stat1 = bool(s - a[-1] - a[-1] in set(a[:-1]))
	stat2 = bool(s - a[-1] - a[-2] == a[-2])
	if stat1 or stat2:
		if a[-1] == s - 2 * a[-1]:
			print(ta.count(a[-1]))
			for i in range(n):
				if ta[i] == a[-1]:
					print(i + 1, end=' ')
		else:
			cnt = 0
			if stat1:
				cnt = a[:-1].count(s - a[-1] - a[-1])
			if stat2:
				cnt += 1
			print(cnt)
			if stat1:
				for i in range(n):
					if ta[i] == s - 2 * a[-1]:
						print(i + 1, end=' ')
			if stat2:
				for i in range(n):
					if ta[i] == a[-1]:
						print(i + 1)
						break
	else:
		print(0)


n = int(input())
l = list(map(int, input().strip().split()))
m = []
for i in range(len(l)):
	m.append([l[i], i + 1])
m.sort()
sum = 0
for i in l:
	sum += i
ans = []
if sum - m[-1][0] - m[-2][0] == m[-2][0]:
	ans.append(m[-1][1])
sum -= m[-1][0]
for i in range(len(m) - 1):
	if sum - m[i][0] == m[-1][0]:
		ans.append(m[i][1])
print(len(ans))
for i in ans:
	print(i, end=' ')


n = int(input())
a = list(map(int, input().split()))
c = [0 for i in range(1000001)]
s = sum(a)
ans = []
for i in a:
	c[i] += 1
for i in range(n):
	s -= a[i]
	c[a[i]] -= 1
	if s % 2 == 0 and s // 2 <= 1000000 and (c[s // 2] > 0):
		ans.append(i)
	s += a[i]
	c[a[i]] += 1
print(len(ans))
for i in ans:
	print(i + 1, end=' ')


input()
tab = [*map(int, input().split())]
suma = sum(tab)
liczby = [0 for x in range(1000007)]
search = [0 for x in range(1000007)]
answer = []
for value in tab:
	liczby[value] = liczby[value] + 1
for value in tab:
	rest = suma - value
	if rest % 2 != 0 or rest == 0:
		continue
	rest = int(rest / 2)
	if rest > 1000000:
		continue
	if liczby[rest] > 0 and rest != value:
		search[value] = 1
	elif liczby[rest] > 1:
		search[value] = 1
i = 0
for value in tab:
	if search[value] > 0:
		answer.append(i + 1)
	i = i + 1
print(str(len(answer)))
for value in answer:
	print(str(value))


n = int(input())
a = [int(i) for i in input().split()]
(s, b) = (sum(a), sorted(a)[-2:])
k = [x for (x, y) in enumerate(a, 1) if s - y == 2 * b[y != b[1]]]
print(len(k))
print(*k)


import sys
import collections

def solve(array):

	def verify(i):
		num = array[i]
		csum = tsum - num
		if csum % 2 == 0:
			val = csum // 2
			if val == num and tdict[val] > 1 or (val != num and tdict[val] > 0):
				return True
		return False
	tsum = sum(array)
	tdict = collections.Counter(array)
	return [str(i + 1) for i in range(len(array)) if verify(i)]
n = int(sys.stdin.readline())
for line in sys.stdin:
	array = list(map(int, line.split()))
	out = solve(array)
	print(len(out))
	print(' '.join(out))


from sys import stdin, stdout

def main():
	n = int(stdin.readline())
	a = [(i, u) for (i, u) in enumerate(list(map(int, stdin.readline().split())))]
	a.sort(key=lambda x: x[1])
	ans = []
	p = [a[0][1]] * n
	for i in range(1, n):
		p[i] = p[i - 1] + a[i][1]
	for i in range(n):
		if i == n - 1:
			try:
				x = p[n - 3]
				if x == a[n - 2][1]:
					ans.append(a[n - 1][0])
			except:
				pass
		else:
			try:
				x = p[n - 2] - a[i][1]
				if x == a[n - 1][1]:
					ans.append(a[i][0])
			except:
				pass
	if not ans:
		stdout.write('%d\n' % 0)
	else:
		stdout.write('%d\n' % len(ans))
		for u in ans:
			stdout.write('%d ' % (u + 1))
		stdout.write('\n')
main()


n = int(input())
arr = list(map(int, input().strip().split()))
mp = {}
s = 0
for i in range(n):
	if arr[i] not in mp:
		mp[arr[i]] = 1
	else:
		mp[arr[i]] += 1
	s += arr[i]
ans = []
for i in range(n):
	if (s - arr[i]) % 2 == 0:
		if (s - arr[i]) // 2 in mp:
			if mp[arr[i]] >= 2 or arr[i] != (s - arr[i]) // 2:
				ans.append(i + 1)
if ans == []:
	print(0)
else:
	print(len(ans))
	print(*ans)


n = int(input())
arr = list(map(int, input().split(' ')))
s = sum(arr)
maxV = max(arr)
count = [0] * (maxV + 1)
for i in arr:
	count[i] += 1
sol = []
for i in range(n):
	s -= arr[i]
	count[arr[i]] -= 1
	if s % 2 == 0:
		if s <= maxV * 2 and count[s // 2] > 0:
			sol.append(str(i + 1))
	s += arr[i]
	count[arr[i]] += 1
print(len(sol))
print(' '.join(sol))


import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
d = sorted(a)
b = sum(a)
c = []
for i in range(n):
	if a[i] == d[-1]:
		if (b - a[i]) % 2 == 0 and (b - a[i]) // 2 == d[-2]:
			c.append(i + 1)
	elif (b - a[i]) % 2 == 0 and (b - a[i]) // 2 == d[-1]:
		c.append(i + 1)
print(len(c))
print(*c)


n = int(input())
a = list(map(int, input().split()))
m = max(a)
cnt = [0] * (m + 1)
for i in a:
	cnt[i] += 1
summ = sum(a)
ans = []
for i in range(n):
	x = a[i]
	summ -= x
	cnt[x] -= 1
	if summ % 2 == 0:
		hlf = summ // 2
		if hlf <= m and cnt[hlf] > 0:
			ans.append(i + 1)
	summ += x
	cnt[x] += 1
print(len(ans))
print(*ans)


import os
import sys
from io import BytesIO, IOBase
from collections import Counter

def main():
	n = int(input())
	a = list(map(int, input().split()))
	b = Counter(a)
	z = sum(a)
	c = []
	for (i, v) in enumerate(a):
		z -= v
		b[v] -= 1
		if not z % 2:
			if b[z // 2]:
				c.append(i + 1)
		b[v] += 1
		z += v
	print(len(c))
	print(*c)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


cnt = lambda s, x: s.count(x)
ii = lambda : int(input())
si = lambda : input()
f = lambda : map(int, input().split())
dgl = lambda : list(map(int, input()))
il = lambda : list(map(int, input().split()))
n = ii()
l = il()
lenm = {}
l1 = []
x = 0
for i in range(1, n + 1):
	lenm[i] = l[i - 1]
lenm = sorted(lenm.items(), key=lambda ky: (ky[1], ky[0]))
if n > 2:
	for i in range(n - 2):
		x += lenm[i][1]
	if x == lenm[n - 2][1]:
		l1.append(lenm[n - 1][0])
	x += lenm[n - 2][1]
	for i in range(n - 1):
		y = x - lenm[i][1]
		if y == lenm[n - 1][1]:
			l1.append(lenm[i][0])
	print(len(l1))
	print(*l1)
else:
	print(0)


n = int(input())
a = list(map(int, input().split()))
cnt = [0] * (int(10 ** 6) + 5)
s = sum(a)
for i in range(n):
	cnt[a[i]] += 1
ans = []
for i in range(n):
	s = s - a[i]
	cnt[a[i]] -= 1
	if s % 2 == 0:
		pos = s // 2
		if pos < 10 ** 6 + 1:
			if cnt[pos] > 0:
				ans.append(i + 1)
	s = s + a[i]
	cnt[a[i]] += 1
print(len(ans))
print(*ans)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import ceil

def lmii():
	return list(map(int, input().split()))
n = int(input())
nums = lmii()
big = [-1, -1]
for i in nums:
	if i > big[0]:
		big[1] = int(big[0])
		big[0] = i
	elif i > big[1]:
		big[1] = i
tot = 0
for i in nums:
	tot += i
counter = 0
ans = []
for i in range(len(nums)):
	if nums[i] == big[0]:
		target = big[1]
	else:
		target = big[0]
	if tot - nums[i] - target == target:
		ans.append(i + 1)
		counter += 1
print(counter)
print(*ans)


n = int(input())
l = list(map(int, input().split()))
max1 = max(l)
second_max = 0
for i in range(n):
	if second_max < l[i] and l[i] != max1:
		second_max = l[i]
sum1 = sum(l)
ans = []
c = 0
if second_max == 0:
	second_max = max1
flag = 0
if l.count(max1) == 1:
	flag = 1
for i in range(n):
	sum2 = sum1 - l[i]
	if l[i] == max1 and flag == 1:
		max2 = second_max
	else:
		max2 = max1
	if sum2 - max2 == max2:
		c += 1
		ans.append(i + 1)
print(c)
if c != 0:
	for i in ans:
		print(i, end=' ')


n = int(input())
A = list(map(int, input().split()))
S = sum(A)
X = [(A[i], i + 1) for i in range(n)]
X.sort()
i = 0
j = n - 1
ANSLIST = []
while i < n and j >= 0:
	if (S - X[i][0]) % 2 == 1:
		i += 1
		continue
	h = (S - X[i][0]) // 2
	while j >= 0:
		if h < X[j][0]:
			j -= 1
			continue
		elif h == X[j][0]:
			if X[i][1] == X[j][1]:
				j -= 1
				continue
			ANSLIST.append(X[i][1])
			i += 1
			break
		elif h > X[j][0]:
			j = min(n - 1, j + 1)
			i += 1
			break
print(len(ANSLIST))
for an in ANSLIST:
	print(an, end=' ')


def main():
	N = int(input())
	A = [int(i) for i in input().split()]
	B = sorted(((a, i) for (i, a) in enumerate(A)))
	ma = B[-1][0]
	ma_idx = B[-1][1]
	ma2 = B[-2][0]
	SR = [0] * (N + 2)
	SL = [0] * (N + 2)
	for i in range(N):
		SL[i + 1] = SL[i] + A[i]
	for i in range(N):
		SR[N - i - 1] = SR[N - i] + A[N - i - 1]
	S = sum(A)
	ans = []
	for i in range(N):
		if i == ma_idx:
			continue
		cur_S = SL[i] + SR[i + 1]
		if cur_S - ma == ma:
			ans.append(i + 1)
	if S - ma - ma2 == ma2:
		ans.append(ma_idx + 1)
	print(len(ans))
	print(*ans)
main()


import math
n = int(input())

def fun(itm):
	return itm[0]

def sm(l):
	s = 0
	for i in l:
		s += i[0]
	return s
l1 = list(map(int, input().split()))
for i in range(n):
	l1[i] = [l1[i], i]
ans = []
l = sorted(l1, key=fun)
s = sm(l) - l[n - 1][0]
for i in range(n - 1):
	if s - l[i][0] == l[n - 1][0]:
		ans.append(l[i][1] + 1)
if s - l[n - 2][0] == l[n - 2][0]:
	ans.append(l[n - 1][1] + 1)
print(len(ans))
for i in ans:
	print(i, end=' ')


n = int(input())
A = list(map(int, input().split()))
s = sum(A)
s1 = s - max(A)
A = [(A[i], i + 1) for i in range(n)]
A.sort()
res = []
for i in range(n - 1):
	if s1 - A[i][0] == A[-1][0]:
		res.append(A[i][1])
if s1 - A[-2][0] == A[-2][0]:
	res.append(A[-1][1])
print(len(res))
for i in range(len(res)):
	print(res[i], end=' ')


3.5
n = int(input())
A = [int(s) for s in input().split(' ') if s != '']
B = [(x, i) for (i, x) in enumerate(A)]
B.sort()
_sum = sum(A)
L = []
for (i, (x, j)) in enumerate(B):
	__sum = _sum - x
	if i == len(A) - 1:
		_max = B[-2][0]
	else:
		_max = B[-1][0]
	__sum -= _max
	if __sum == _max:
		L.append(j + 1)
print(len(L))
if len(L) != 0:
	for i in range(0, len(L) - 1):
		print(L[i], end=' ')
	print(L[-1])


from sys import stdin
n = int(input())
l = list(map(int, stdin.readline().rstrip().split(' ')))
s = 0
dic = {}
for i in range(n):
	x = dic.get(l[i], 0)
	if x:
		dic[l[i]] += 1
	else:
		dic[l[i]] = 1
	s = s + l[i]
r = []
c = 0
for i in range(n):
	t = s - l[i]
	if t % 2 == 0:
		check = dic.get(t // 2, 0)
		if t // 2 == l[i] and check > 1:
			c += 1
			r.append(i + 1)
		elif check and t // 2 != l[i]:
			c += 1
			r.append(i + 1)
if c:
	print(c)
	print(*r)
else:
	print(0)


import sys
from itertools import accumulate

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7

class SegTree:

	def __init__(self, n, func, intv, A=[]):
		self.n = n
		self.func = func
		self.intv = intv
		n2 = 1
		while n2 < n:
			n2 <<= 1
		self.n2 = n2
		self.tree = [self.intv] * (n2 << 1)
		if A:
			for i in range(n):
				self.tree[n2 + i] = A[i]
			for i in range(n2 - 1, -1, -1):
				self.tree[i] = self.func(self.tree[i * 2], self.tree[i * 2 + 1])

	def update(self, i, x):
		i += self.n2
		self.tree[i] = x
		while i > 0:
			i >>= 1
			self.tree[i] = self.func(self.tree[i * 2], self.tree[i * 2 + 1])

	def add(self, i, x):
		self.update(i, self.get(i) + x)

	def query(self, a, b):
		l = a + self.n2
		r = b + self.n2
		s = self.intv
		while l < r:
			if r & 1:
				r -= 1
				s = self.func(s, self.tree[r])
			if l & 1:
				s = self.func(s, self.tree[l])
				l += 1
			l >>= 1
			r >>= 1
		return s

	def get(self, i):
		return self.tree[i + self.n2]

	def all(self):
		return self.tree[1]

	def print(self):
		for i in range(self.n):
			print(self.get(i), end=' ')
		print()
N = INT()
A = LIST()
st = SegTree(N, max, 0, A)
sm = sum(A)
ans = []
for (i, a) in enumerate(A):
	st.update(i, 0)
	mx = st.all()
	sm -= a
	if sm - mx == mx:
		ans.append(i + 1)
	st.update(i, a)
	sm += a
print(len(ans))
print(*ans)


from sys import stdin
input = stdin.readline
n = int(input())
arr = [int(x) for x in input().split()]
d = {}
for i in range(n):
	if arr[i] in d:
		d[arr[i]].append(i)
	else:
		d[arr[i]] = [i]
ans = []
s = sum(arr)
for i in range(n):
	if arr[i] < s - arr[i]:
		x = s - arr[i] - arr[i]
		if x in d:
			for j in d[x]:
				if j != i:
					ans.append(j + 1)
s = set(ans)
ans = list(s)
print(len(ans))
print(*ans)


from collections import Counter
n = int(input())
a = [*map(int, input().split())]
(ans, s, c) = ([], sum(a), Counter(a))
for i in range(n):
	t = s - a[i]
	if not t & 1 and t // 2 in c:
		if c[t // 2] == 1:
			if t // 2 != a[i]:
				ans.append(i + 1)
		else:
			ans.append(i + 1)
print(len(ans))
print(' '.join(map(str, ans)))


input()
array = list(map(int, input().split(' ')))
sum_of_array = sum(array)
(second_max, first_max) = sorted(array)[-2:]
answer = []
for (index, each) in enumerate(array, 1):
	existing_sum = sum_of_array - each
	existing_max = second_max if each == first_max else first_max
	if existing_sum == existing_max * 2:
		answer.append(index)
print(len(answer))
print(*answer)


n = int(input())
a = [int(x) for x in input().split()]
m = max(a)
s = sum(a)
cnt = len([i for i in a if i == m])
mm = 0
for i in a:
	if i != m and i > mm:
		mm = i
ans = []
for i in range(len(a)):
	if a[i] == m:
		if cnt == 1:
			c = mm
		else:
			c = m
		if s - c - a[i] == c:
			ans.append(i + 1)
	elif s - m - a[i] == m:
		ans.append(i + 1)
print(len(ans))
print(' '.join([str(i) for i in ans]))


import sys
n = int(sys.stdin.readline())
a = list(map(int, sys.stdin.readline().split()))
s = sum(a)
a = [[a[i], i + 1] for i in range(n)]
a.sort(key=lambda x: x[0])
arr = []
for i in range(n):
	last_ind = n - 1 if i < n - 1 else n - 2
	if s - a[i][0] == 2 * a[last_ind][0]:
		arr.append(a[i][1])
print(len(arr))
for a in arr:
	sys.stdout.write('%s ' % a)


n = int(input())
l = list(map(int, input().split()))
d = dict()
summ = sum(l)
for i in range(n):
	if l[i] in d:
		d[l[i]].append(i)
	else:
		d[l[i]] = []
		d[l[i]].append(i)
kList = list(d.keys())
kList.sort(reverse=True)
resList = []
count = 0
for x in kList:
	if count > 1:
		break
	count = count + 1
	tmpSum = summ - x
	if count == 1:
		if len(d[x]) == 2:
			if tmpSum - x == x:
				resList = resList + d[x]
		if len(d[x]) == 3 and len(kList) == 1:
			resList = resList + d[x]
		for i in range(1, len(kList)):
			tmpSum2 = int(tmpSum - kList[i])
			if tmpSum2 == x:
				resList = resList + d[kList[i]]
				break
			if tmpSum2 > x:
				break
	if count == 2:
		if tmpSum - kList[0] == x:
			resList = resList + d[kList[0]]
print(len(resList))
for x in resList:
	print(x + 1, end=' ')


n = int(input())
arr = [int(i) for i in input().split()]
ans = 0
total = sum(arr)
sum_w_idx = []
value_appear = {}
for i in range(len(arr)):
	sum_w_idx.append(total - arr[i])
	if arr[i] in value_appear:
		value_appear[arr[i]].append(i)
	else:
		value_appear[arr[i]] = [i]
passs = {}
arr_ans = []
for i in range(len(sum_w_idx)):
	if sum_w_idx[i] in passs:
		ans += 1
		arr_ans.append(i + 1)
	elif sum_w_idx[i] % 2 == 0:
		val = sum_w_idx[i] // 2
		if val in value_appear:
			for v in value_appear[val]:
				if v != i:
					ans += 1
					passs[sum_w_idx[i]] = 1
					arr_ans.append(i + 1)
					break
if ans == 0:
	print(0)
else:
	print(ans)
	print(*arr_ans)


n = int(input())
arr = list(map(int, input().split(' ')))
res = []
m = max(arr)
m_i = arr.index(m)
s = sum(arr)
for i in range(n):
	if i == m_i:
		continue
	if s - arr[i] - m == m:
		res.append(i + 1)
arr.pop(m_i)
m = max(arr)
arr.remove(m)
if sum(arr) == m:
	res.append(m_i + 1)
if not res:
	print(0)
else:
	print(len(res))
	print(' '.join(map(str, res)))


import sys

def fi():
	return sys.stdin.readline()
d = dict()
n = int(fi())
l = list(map(int, fi().split()))
s = sum(l)
for i in range(n):
	d.setdefault(l[i], [])
	d[l[i]].append(i + 1)
c = 0
ans = []
for (q, v) in d.items():
	a = (s - q) / 2
	b = len(v)
	b -= 1
	if d.get(a) and q != a or (q == a and b):
		c += b + 1
		ans.extend(v)
print(c)
print(*ans)


from bisect import bisect_right as br
from bisect import bisect_left as bl
from collections import defaultdict
import sys
import math
MAX = sys.maxsize
MAXN = 10 ** 6 + 10

def isprime(n):
	n = abs(int(n))
	if n < 2:
		return False
	if n == 2:
		return True
	if not n & 1:
		return False
	for x in range(3, int(n ** 0.5) + 1, 2):
		if n % x == 0:
			return False
	return True

def mhd(a, b, x, y):
	return abs(a - x) + abs(b - y)

def numIN():
	return map(int, sys.stdin.readline().strip().split())

def charIN():
	return sys.stdin.readline().strip().split()

def maxSubArraySum(a, size):
	max_so_far = 0
	max_ending_here = 0
	for i in range(size):
		max_ending_here = max_ending_here + a[i]
		if max_ending_here < 0:
			max_ending_here = 0
		elif max_so_far < max_ending_here:
			max_so_far = max_ending_here
	return max_so_far
n = int(input())
l = list(numIN())
z = [(i, l[i]) for i in range(n)]
z.sort(key=lambda x: x[1])
ans = []
s = sum(l) - z[-1][1]
for i in z[:n - 1]:
	if s - i[1] == z[-1][1]:
		ans.append(str(i[0] + 1))
for i in z[:n - 1]:
	if s - i[1] == i[1]:
		ans.append(str(z[-1][0] + 1))
		break
print(len(ans))
print(' '.join(ans))


x = int(input())
s = list(map(int, input().split()))
dp = []
for n in range(x):
	dp.append([s[n], n + 1])
s.sort()
dp.sort()
for n in range(1, x):
	dp[n][0] += dp[n - 1][0]
a = s[-1]
b = dp[-2][0]
res = []
for n in range(x - 1):
	if b - s[n] == a:
		res.append(dp[n][1])
if x > 2:
	if dp[x - 3][0] == s[x - 2]:
		res.append(dp[-1][1])
print(len(res))
print(*res)


from collections import defaultdict
n = int(input())
l = list(map(int, input().split()))
s = sum(l)
ans = []
hash = defaultdict(int)
bash = defaultdict(list)
seti = set()
for i in range(n):
	hash[l[i]] += 1
	seti.add(l[i])
	bash[l[i]].append(i)
for i in range(n):
	z = s - l[i]
	if z % 2 == 0:
		if z // 2 in seti:
			if z // 2 != l[i]:
				ans.append(i + 1)
			elif hash[l[i]] > 1:
				ans.append(i + 1)
print(len(ans))
print(*ans)


import sys
import math
import collections
import operator as op
from collections import deque
from math import gcd, inf, sqrt, pi, cos, sin, ceil, log2, floor, log
from bisect import bisect_right, bisect_left, bisect
from functools import reduce
from sys import stdin, stdout, setrecursionlimit
setrecursionlimit(2 ** 20)

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return list(factors)

def isPowerOfTwo(x):
	return x and (not x & x - 1)
MOD = 1000000007
PMOD = 998244353
N = 10 ** 6
LOGN = 30
alp = 'abcdefghijklmnopqrstuvwxyz'
T = 1
for _ in range(T):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().rstrip().split()))
	A = a.copy()
	A.sort()
	b = []
	s = sum(a)
	for i in range(n):
		b.append([a[i], i + 1])
	b.sort()
	ans = []
	for i in range(n):
		if (s - a[i]) % 2 == 0:
			val = (s - a[i]) // 2
			x = bisect_left(A, val)
			if x == n:
				continue
			if A[x] == val and i + 1 != b[x][1]:
				ans.append(i + 1)
			elif x + 1 < n:
				if A[x + 1] == val:
					ans.append(i + 1)
	print(len(ans))
	print(*ans)


def main():
	count = int(input())
	arr = input().split(' ')
	store = []
	tot = 0
	biggest = 0
	second_biggest = 0
	index_biggest = 0
	index_second_biggest = 0
	for x in range(count):
		test = int(arr[x])
		store.append(test)
		tot += test
		if test >= biggest:
			(biggest, second_biggest) = (test, biggest)
			(index_biggest, index_second_biggest) = (x, index_biggest)
		elif test > second_biggest:
			second_biggest = test
			index_second_biggest = x
	number = 0
	string = ''
	for x in range(count):
		if store[x] == biggest:
			if tot - store[x] == 2 * second_biggest:
				number += 1
				string += str(x + 1) + ' '
		elif tot - store[x] == 2 * biggest:
			number += 1
			string += str(x + 1) + ' '
	print(number)
	print(string)
main()


n = int(input())
a = list(map(int, input().split()))
if n <= 2:
	print(0)
	print()
	exit()
lis = [[a[i], i] for i in range(n)]
lis.sort()
a.sort()
ans = []
aa = sum(a[:-2])
if aa == lis[-2][0]:
	ans.append(lis[-1][1] + 1)
aa += a[-2]
for i in range(n - 1):
	if aa - lis[i][0] == a[-1]:
		ans.append(lis[i][1] + 1)
print(len(ans))
print(*ans)


n = int(input())
a = list(map(int, input().split()))
k = 0
s = ''
f = sum(a)
b = []
max1 = 0
max2 = 0
x = -1
for i in range(n):
	if a[i] >= max1:
		max2 = max1
		max1 = a[i]
	elif a[i] > max2:
		max2 = a[i]
for i in range(n):
	d = a[i]
	a[i] = 0
	if max1 != d:
		if max1 == f - max1 - d:
			b.append(i + 1)
			k += 1
	elif max2 == f - max2 - d:
		b.append(i + 1)
		k += 1
	a[i] = d
print(k)
print(*b)


N = int(input())
s = list(map(int, input().split()))
ori = s[:]
s.sort()
sm = sum(s)
ans = []
A = []
for i in range(N - 1):
	if sm - s[i] - s[-1] == s[-1]:
		ans.append(s[i])
if sm - s[-1] - s[-2] == s[-2]:
	ans.append(s[-1])
for i in range(N):
	if ori[i] in ans:
		A.append(i + 1)
print(len(A))
print(*A)


n = int(input())
if n == 1:
	print(0)
	exit()
inp = input().split(' ')
for i in range(n):
	inp[i] = int(inp[i])
mx = inp[0]
mxind = 0
mx2 = inp[1]
s = 0
for i in range(n):
	if inp[i] > mx:
		mx2 = mx
		mx = inp[i]
		mxind = i
	elif inp[i] > mx2 and i != mxind:
		mx2 = inp[i]
	s += inp[i]
sum = [0 for i in range(n)]
mxit = [0 for i in range(n)]
for i in range(n):
	sum[i] = s - inp[i]
	if inp[i] == mx:
		mxit[i] = mx2
	else:
		mxit[i] = mx
cnt = 0
ans = []
for i in range(n):
	if sum[i] - mxit[i] == mxit[i]:
		cnt += 1
		ans.append(i + 1)
print(cnt)
joined_string = ' '.join([str(v) for v in ans])
print(joined_string)


gcd = lambda a, b: gcd(b, a % b) if b else a

def main():
	n = int(input())
	arr = list(map(int, input().split()))
	summ = sum(arr)
	ind = []
	(fm, sm) = (arr[0], -1)
	ind_fm = 0
	for i in range(len(arr)):
		if arr[i] > fm:
			fm = arr[i]
			ind_fm = i
	for i in range(len(arr)):
		if arr[i] > sm and i != ind_fm:
			sm = arr[i]
	for i in range(len(arr)):
		if i != ind_fm and summ - arr[i] - fm == fm:
			ind.append(i + 1)
		if i == ind_fm and summ - arr[i] - sm == sm:
			ind.append(i + 1)
	print(len(ind))
	print(*ind)
main()


n = int(input())
a = list(map(int, input().split()))
k = []
total = 0
d = {}
for i in range(n):
	total += a[i]
	if not a[i] in d:
		d[a[i]] = 0
	d[a[i]] += 1
for i in range(n):
	if (total - a[i]) % 2 == 0:
		result = (total - a[i]) / 2
		try:
			if d[result]:
				if result == a[i] and d[result] > 1:
					k.append(i + 1)
				elif result != a[i]:
					k.append(i + 1)
		except:
			pass
print(len(k))
if len(k):
	print(*k)


n = int(input())
a = list(map(int, input().split()))
sum = 0
maxx = -1
submax = -1
for i in range(n):
	sum += a[i]
	if maxx == -1 or a[i] > a[maxx]:
		submax = maxx
		maxx = i
	elif submax == -1 or a[i] > a[submax]:
		submax = i
ans = 0
b = []
for i in range(n):
	if i == maxx:
		if sum - a[i] == a[submax] * 2:
			b.append(i + 1)
			ans += 1
	elif sum - a[i] == a[maxx] * 2:
		b.append(i + 1)
		ans += 1
print(ans)
for i in range(ans):
	print(b[i], end=' ')
print()


n = int(input())
a = [int(x) for x in input().split()]
summ = sum(a)
ans = []
q = sorted(a)
maks = q[-1]
maks2 = q[-2]
for i in range(n):
	cout = maks
	if a[i] == maks:
		cout = maks2
	if summ - a[i] == 2 * cout:
		ans.append(i + 1)
print(len(ans))
print(*ans)