import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.HashMap; import java.util.Map; import java.util.PriorityQueue; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); String[] sa = br.readLine().split(" "); long[] a = new long[n]; for (int i = 0; i < n; i++) { a[i] = Integer.parseInt(sa[i]); } br.close(); if (n >= 4) { PrintWriter pw = new PrintWriter(System.out); pw.println(0); for (int i = 0; i < n - 1; i++) { pw.println("1 2"); } pw.flush(); } else if (n == 2) { Map map0 = bunkai(a[0]); Map map1 = bunkai(a[1]); long m = (a[0] - 1) * (a[1] - 1); for (Long k : map0.keySet()) { if (map1.containsKey(k)) { m = 0; break; } } System.out.println(m); System.out.println("1 2"); } else { Map map0 = bunkai(a[0]); Map map1 = bunkai(a[1]); Map map2 = bunkai(a[2]); Map map01 = bunkai((a[0] - 1) * (a[1] - 1)); Map map12 = bunkai((a[1] - 1) * (a[2] - 1)); Map map20 = bunkai((a[2] - 1) * (a[0] - 1)); for (Long k : map0.keySet()) { if (map12.containsKey(k)) { System.out.println(0); System.out.println("2 3"); System.out.println("1 2"); return; } } for (Long k : map1.keySet()) { if (map20.containsKey(k)) { System.out.println(0); System.out.println("1 3"); System.out.println("1 2"); return; } } for (Long k : map2.keySet()) { if (map01.containsKey(k)) { System.out.println(0); System.out.println("1 2"); System.out.println("1 2"); return; } } PriorityQueue que = new PriorityQueue<>((o1, o2) -> o1.a - o2.a); for (int i = 0; i < n; i++) { Obj o = new Obj(); o.i = i; o.a = (int) a[i]; que.add(o); } Obj f = que.poll(); long m = f.a; Obj o1 = que.poll(); Obj o2 = que.poll(); m = (m - 1) * (o1.a - 1); m = (m - 1) * (o2.a - 1); System.out.println(m); System.out.println((f.i + 1) + " " + (o1.i + 1)); System.out.println("1 2"); } } static class Obj { int i, a; } static Map bunkai(long n) { Map soinsu = new HashMap<>(); int end = (int) Math.sqrt(n); long d = 2; while (n > 1) { if (n % d == 0) { n /= d; soinsu.put(d, soinsu.getOrDefault(d, 0) + 1); end = (int) Math.sqrt(n); } else { if (d > end) { d = n - 1; } d++; } } return soinsu; } }