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

public class Task22 {
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            StringTokenizer st = new StringTokenizer(br.readLine());
            int n = Integer.parseInt(st.nextToken());
            int[] a = new int[n];

            st = new StringTokenizer(br.readLine());
            int sum = 0;
            for (int i = 0; i < n; i++) {
                a[i] = Integer.parseInt(st.nextToken());
                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];
                    for(int j = 0; j < a.length-1; j++) {
                        if(cur > target) break;
                        cur += a[(i + j) % a.length];
                        if(cur == target) {
                            cur = 0;
                            result.add(j + 1);
                        }
                    }
                    if(result.size() == 3) {
                        System.out.println(0);
                        for (Integer integer : result) {
                            System.out.print(integer + " ");
                        }
                        break;
                    } else {
                        cur = 0;
                        result.clear();
                    }
                }
            }
        }catch(Exception e) {}

    }
}

/*

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