import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.stream.Collectors;

public class Task22 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
            int n = sc.nextInt();
            int[] a = new int[n];
            int sum = 0;
            for (int i = 0; i < n; i++) {
                a[i] = sc.nextInt();
                sum += a[i];
            }
            if(sum % 3 == 0) {
                int target = sum / 3;
                int cur = 0;
                List<Integer> result = new ArrayList<>();
                for(int i = 0; i < a.length; i++) {
                    cur += a[i];
                    if(cur == target) {
                        cur = 0;
                        result.add((i + 1) % a.length);
                    }
                    boolean needToAdd = true;
                    for(int j = 1; j < a.length; j++) {
                        if(cur > target) break;
                        if(needToAdd) {
                            int toAdd = (i + j) % a.length + 1;
                            result.add(toAdd);
                            needToAdd = false;
                        }
                        cur += a[(i + j) % a.length];
                        if(cur == target) {
                            cur = 0;
                            needToAdd = true;
                        }
                    }
                    if(result.size() == 3) {
                        System.out.println(0);
                        for (int j = 0; j < result.size(); j++) {
                            System.out.print(result.get(j) + (j == result.size() - 1 ? "" : " "));
                        }
                        break;
                    } else {
                        cur = 0;
                        result.clear();
                    }
                }
            }

    }
}


/*

6
1 2 2 4 0 3

7
2 1 6 1 0 5 3

 */
/*

9
1 1 1 1 1 1 1 1 1
 */
