#include <cstdio>
#include <cstring>
#include <cctype>
#include <algorithm>

using namespace std;

int getint()
{
    char ch=getchar();
    int f=1,x=0;
    while(!isdigit(ch)){if(ch=='-') f=-1; ch=getchar();}
    while(isdigit(ch)){x=x*10+ch-'0'; ch=getchar();}
    return f*x;
}

const int N=16;

int n,m;
int map[N][N];
int f[1<<15][N];
int slf[1<<15],ot[1<<15][N];
int tot;

void init()
{
    n=getint(),m=getint();
    for(int i=1; i<=m; i++){
        int u=getint(),v=getint(),w=getint();
        map[u][v]=map[v][u]=w;
        tot+=w;
    }
    for(int s=1; s<(1<<n); s++){
        for(int j=1; j<=n; j++){
            if(s&(1<<(j-1))){
                for(int k=j+1; k<=n; k++){
                    if(!(s&(1<<(k-1)))) continue;
                    slf[s]+=map[j][k];
                }
            }else{
                for(int k=1; k<=n; k++){
                    if(!(s&(1<<(k-1)))) continue;
                    ot[s][j]+=map[j][k];
                }
            }
        }
    }
}

int main()
{
    init();
    memset(f,128,sizeof(f));
    f[1][1]=0;
    for(int s=1; s<(1<<n); s+=2){
        for(int i=1; i<=n; i++){
            if(!(s&(1<<(i-1)))) continue;
            for(int t=s&(s-1); t; t=s&(t-1)){
                if(!(t&1)) continue;
                f[s][i]=max(f[s][i],f[t][i]+slf[s^t]+ot[s^t][i]);
            }
            for(int j=1; j<=n; j++){
                if(i==j || !(s&(1<<(j-1)))) continue;
                if(map[i][j]==0) continue;
                f[s][i]=max(f[s][i],f[s^(1<<(i-1))][j]+map[i][j]);
            }
        }
    }
    printf("%d\n",tot-f[(1<<n)-1][n]);
    return 0;
}

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

const double eps = 1e-1;

int main() {
    int n; cin >> n;
    vll x;
    rep(i,n) {
        double f; cin >> f;
        f *= inf;
        ll l = ll(f+eps);
        x.push_back(l);
    }
    vvint data(50,vint(50,0));
    vector<P> ct;
    rep(i,n) {
        int ct_2 = 0, ct_5 = 0;
        while (x[i] % 2 == 0) {
            ct_2++;
            x[i] /= 2;
        }
        while (x[i] % 5 == 0) {
            ct_5++;
            x[i] /= 5;
        }
        data[ct_2][ct_5]++;
        ct.push_back(P(ct_2,ct_5));
    }
    rep(i,50)rep(j,50) {
        if (i != 0) data[i][j] += data[i-1][j];
        if (j != 0) data[i][j] += data[i][j-1];
        if (i != 0 && j != 0) data[i][j] -= data[i-1][j-1];
    }
    ll ans = 0;
    rep(i,n) {
        int ct_2 = max(0,18 - ct[i].first);
        int ct_5 = max(0,18 - ct[i].second);
        int tmp = data[49][49];
        if (ct_5 != 0) tmp -= data[49][ct_5-1];
        if (ct_2 != 0) tmp -= data[ct_2-1][49];
        if (ct_5 != 0 && ct_2 != 0) tmp += data[ct_2-1][ct_5-1];
        if (ct_2 <= ct[i].first && ct_5 <= ct[i].second) tmp--;
        ans += tmp;
    }
    ans /= 2;
    cout << ans << endl;
}