import java.io.*; import java.util.*; class Main { static SegmentTree seg; static void update(int x,long d){ seg.update(x,new long[]{Math.max(d,0),d}); } public static void main(String[] args) { MyScanner sc = new MyScanner(); out = new PrintWriter(new BufferedOutputStream(System.out)); int n=sc.nextInt(); int[]t=sc.nextIntArray(n-1); long[]ct=new long[n],dt=new long[n-1]; for(int i=0;i 0) { x = (x - 1) / 2; this.seg[x] = comb(this.seg[2 * x + 1], this.seg[2 * x + 2]); } } long[] query(int a,int b,int l,int r,int k){ if(a<=l&&r<=b)return seg[k]; if(b<=l||r<=a) return new long[]{0,0}; return comb(query(a,b,l,(l+r)/2,2*k+1),query(a,b,(l+r)/2,r,2*k+2)); } long[] query(int l, int r) { return query(l,r,0,SIZE,0); } }