#include<cstdio>
#include<vector>
using namespace std;
vector<int> vec;
int n;
bool visit[25];
int count = 0;
void DFS(int cursize,int pos){
    if(cursize == 40){
        ++count;
        return;
    }
    for(int i = pos ; i< n ;++i){
        if(cursize  + vec[i] > 40 || visit[i] == true ){
            continue;
        }else{
            visit[i] = true;
            DFS(cursize+vec[i],i+1);
            visit[i] = false;
        }
    }
}
int main() {
    int  x;
    scanf("%d", &n);
    for (int i = 0 ; i < n; ++i) {
        scanf("%d", &x);
        vec.push_back(x);
    }
     for (int i = 0 ; i < 25; ++i) {
       visit[i] = false;
    }
    DFS(0,0);
    printf("%d\n",count);
}