An equilibrium index of a sequence is an index into the sequence such that the sum of elements at lower indices is equal to the sum of elements at higher indices.



For example, in a sequence   



A


{\displaystyle A}

:

   




A

0


=
−
7


{\displaystyle A_{0}=-7}


   




A

1


=
1


{\displaystyle A_{1}=1}


   




A

2


=
5


{\displaystyle A_{2}=5}


   




A

3


=
2


{\displaystyle A_{3}=2}


   




A

4


=
−
4


{\displaystyle A_{4}=-4}


   




A

5


=
3


{\displaystyle A_{5}=3}


   




A

6


=
0


{\displaystyle A_{6}=0}


3   is an equilibrium index, because:

   




A

0


+

A

1


+

A

2


=

A

4


+

A

5


+

A

6




{\displaystyle A_{0}+A_{1}+A_{2}=A_{4}+A_{5}+A_{6}}


6   is also an equilibrium index, because:

   




A

0


+

A

1


+

A

2


+

A

3


+

A

4


+

A

5


=
0


{\displaystyle A_{0}+A_{1}+A_{2}+A_{3}+A_{4}+A_{5}=0}


(sum of zero elements is zero)

7   is not an equilibrium index, because it is not a valid index of sequence 



A


{\displaystyle A}

.



Task;
Write a function that, given a sequence, returns its equilibrium indices (if any).

Assume that the sequence may be very long.




PROC PrintArray(INT ARRAY a INT size)
  INT i
 
  Put('[)
  FOR i=0 TO size-1
  DO
    IF i>0 THEN Put(' ) FI
    PrintI(a(i))
  OD
  Put(']) PutE()
RETURN
 
INT FUNC SumRange(INT ARRAY a INT first,last)
  INT sum
  INT i
 
  sum=0
  FOR i=first TO last
  DO
    sum==+a(i)
  OD
RETURN(sum)
 
PROC EquilibriumIndices(INT ARRAY a INT size
     INT ARRAY indices INT POINTER indSize)
  INT i,left,right
 
  indSize^=0
  FOR i=0 TO size-1
  DO
    left=SumRange(a,0,i-1)
    right=SumRange(a,i+1,size-1)
    IF left=right THEN
      indices(indSize^)=i
      indSize^==+1
    FI
  OD
RETURN
 
PROC Test(INT ARRAY a INT size)
  INT ARRAY indices(100)
  INT indSize
 
  EquilibriumIndices(a,size,indices,@indSize)
  Print("Array=") PrintArray(a,size)
  Print("Equilibrium indices=") PrintArray(indices,indSize)
  PutE()
RETURN
 
PROC Main()
  INT ARRAY a=[65529 1 5 2 65532 3 0]
  INT ARRAY b=[65535 1 65535 1 65535 1 65535]
  INT ARRAY c=[1 2 3 4 5 6 7 8 9]
  INT ARRAY d=[0]
 
  Test(a,7)
  Test(b,7)
  Test(c,9)
  Test(d,1)
RETURN