/*--.--.--.--.--.--.--.--.--.--.--.--.--* * By-Anshal Dwivedi * * IT , MNNIT Allahabad * * anshaldwivedi@gmail.com * *--.--.--.--.--.--.--.--.--.--.--.--.--*/ #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define mp make_pair #define pb push_back #define X first #define Y second #define null NULL #define ll long long #define tr(c, itr) for(itr = (c).begin(); itr != (c).end(); itr++) #define present(container, element) (container.find(element) != container.end()) //for set,map,etc #define cpresent(container, element) (find(all(container),element) != container.end()) //for vectors #define all(c) c.begin(),c.end() //eg sort(all(v)); //Initialization #define clr(a) memset(a,0,sizeof(a)) #define ini(a) memset(a,-1,sizeof(a)) //Input Output #define inp(n) scanf("%d",&n) #define inp2(n,m) inp(n), inp(m) #define ins(s) scanf("%s",s) #define inc(n) scanf("%c",&n) #define inlf(n) scanf("%lf",&n) #define inll(n) scanf("%lld",&n) #define inll2(n,m) scanf("%lld%lld",&n,&m) #define out(n) printf("%d\n",n) #define out2(n,m) printf("%d %d\n",n,m) #define outs(d) printf("%s\n",d) #define sout(n) printf("%d ",n) #define outll(n) printf("%lld\n",n) #define soutll(n) printf("%lld ",n) #define outll2(n,m) printf("%lld %lld\n",n,m) #define nl printf("\n"); //loops #define rep(i,n) for(int i=0;i=a;i--) //const #define mod 1000000007 #define MOD_INV 1000000006 #define MAX 100009 #define INF 999999999 #define PI 3.14159265358979323846264338327 ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0){if (exp & 1) result = (result * base) % modulus; base = (base * base) % modulus;exp >>= 1;}return result;} ll fact[1300],invfact[1300]; int n,a[1300]; ll dp[1305][1304]; ll ncr(int n,int r){ if(r>n) return 0; return (fact[n]*invfact[n-r])%mod; } ll doit(int pos,int aval){ if(pos==n) return 1; if(pos>n) return 0; ll ans=0; if(dp[pos][aval]!=-1) return dp[pos][aval]; int el=0; for(int i=pos;i