#include <iostream>
using namespace std;

const int N = 50;
int path[N];
bool visit[N];
int a[N];
int sum_weight;
int sum_method;
int n;

void DFS(int u, int position){//position参数的作用:控制从左往右进行搜索,避免重复搜索
    if(sum_weight == 40){
        sum_method ++;
        return;
    }

    for(int i = position; i < n; i ++){
        if(!visit[i] && sum_weight + a[i] <= 40){
            visit[i] = true;
            path[u] = i;
            sum_weight += a[i];
            DFS(u + 1, i + 1);
            sum_weight -= a[i];
            visit[i] = false;
        }
    }
}

int main() {
    cin >> n;
    for(int i = 0; i < n; i ++){
        cin >> a[i];
    }

    DFS(0, 0);
    cout << sum_method << endl;

    return 0;
}