import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Scanner; public class Main { public static void main(String[] arg) {
Scanner scanner = new Scanner(System.in); int inp = scanner.nextInt();
String nu = scanner.nextLine();
String str = scanner.nextLine();
String[] strs = str.split(" ");
List<Integer> lists = new ArrayList<>(); for (int i = 0; i < strs.length; i++) {
lists.add(i, Integer.parseInt(strs[i]));
}
System.out.println(test(lists));
} public static float test(List<Integer> str) { float count = 0; float t = 0; for (int j = 0; j < str.size(); j++) { if (str.get(j) == 2){
str.set(j,1); float t1 = test(str);
str.set(j,2);
str.set(j,0); float t2 = test(str);
str.set(j,2);
count = (t1+t2)/2; return count;
} if (str.get(j) == 1) {
t = t + 1;
count = count + t;
} if (str.get(j) ==0){
t=0;
count =count +0;
}
} return count;
}
}
#360笔试##笔试题目##360公司#