C # implementation of above approach
using System ; class GFG { public static void countWays ( int [ ] a , int n ) { int i , j ; long [ ] suff = new long [ n ] ; if ( a [ n - 1 ] == 2 ) suff [ n - 1 ] = 1 ;