Codeforces Round #521 (Div. 3) C. Good Array

时间:2023-02-07 16:56:48


C. Good Array

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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]a=[1,3,3,7] is good because there is the element a4=7a4=7 which equals to the sum 1+3+31+3+3.

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

For example, if a=[8,3,5,2]a=[8,3,5,2], the nice indices are 11 and 44:

  • if you remove a1a1, the array will look like [3,5,2][3,5,2] and it is good;
  • if you remove a4a4, the array will look like [8,3,5][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 nn (2≤n≤2⋅1052≤n≤2⋅105) — the number of elements in the array aa.

The second line of the input contains nn integers a1,a2,…,ana1,a2,…,an (1≤ai≤1061≤ai≤106) — elements of the array aa.

Output

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

In the second line print kk distinct integers j1,j2,…,jkj1,j2,…,jk in any order — nice indices of the array aa.

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

Examples

input

Copy


5 2 5 1 2 2


output

Copy


3 4 1 5


input

Copy


4 8 3 5 2


output

Copy


2 1 4


input

Copy


5 2 1 2 4 3


output

Copy


0


Note

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

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

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


给你n个数,叫你删除一个数,可以存在n-2个数和sum等于剩下的那个数

两种情况:

剩下的那个数为最大数,从n-1删除查找

删除最大数,剩下那个数为第二大的数,剩下的数是否等于第二大的数

#include<cstdio>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<functional>
#include<cstring>
#include<string>
#include<cstdlib>
#include<iomanip>
#include<numeric>
#include<cctype>
#include<cmath>
#include<ctime>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<map>
using namespace std;
const int N=200005;
typedef long long I64;
int n,m;
int a[N];
vector<int>ans;
int main()
{
int n;
scanf("%d",&n);
I64 sum=0;
int maxx=0;
int pos=0;
for(int i=1;i<=n;i++)
{
scanf("%d",&a[i]);
if(maxx<a[i])
{
maxx=a[i];
pos=i;
}
sum+=a[i];
}
sum-=maxx;
int max1=0;
for(int i=1;i<=n;i++)
{ if(pos!=i)
{
max1=max(max1,a[i]);
if(sum-a[i]==maxx)
{
// cout<<sum-a[i]<<i<<endl;
ans.push_back(i);
}
}
}

if(sum-max1==max1)
{
ans.push_back(pos);
}

cout<<ans.size()<<endl;
for(int k=0;k<ans.size();k++)
{
printf("%d ",ans[k]);
}


return 0;
}
→Judgement Protocol