#include <cstdio>
#include <cstdlib>

#define MAX 15
#define INF 1000000000

#define max(x,y) ((x)>(y)?(x):(y))

int K,M;                             // Number of businessmen, number of "conspiracies"
int ND;                              // Number of possible boat "drivers" (singles or pairs)
int t[MAX];                          // Individual times
int D[MAX+MAX*MAX],T[MAX+MAX*MAX];   // "Drivers" (singles or pairs) and their times
int CM[MAX*MAX],ACM[MAX*MAX];        // Conspiracy Members & Anti-Conspiracy Members
int W[2*(1<<MAX)];                   // Current shortest way to specified position
bool Dead[2*(1<<MAX)];               // Already decided shortest ways
                                     // 0 .. 2^K-1 - boat on the left side
                                     // 2^K .. 2*(2^K)-1 - boat on the right side
inline int p(int x){return 1<<x;}

bool good(int x)
{
    for(int i=0;i<M;i++) if( (((CM[i]&(x))==CM[i])&&((ACM[i]&(x))==0))                      // If conspiracy can occur in the
                          || (((CM[i]&(~x))==CM[i])&&((ACM[i]&(~x))==0)) ) return false;    // left- or right- side party
    return true;
}

int main()
{
    scanf("%d",&K);
    for(int i=0;i<K;i++) scanf("%d",t+i);
    scanf("%d",&M);
    for(int i=0;i<M;i++)
    {
        int x,y,m,q;
        scanf("%d%d",&x,&y);
        CM[i]=p(x-1)|p(y-1);
        scanf("%d",&m);
        ACM[i]=0;
        for(int j=0;j<m;j++) {scanf("%d",&q);ACM[i]|=p(q-1);}
    }
    for(int i=0;i<K;i++) {D[i]=p(i);T[i]=t[i];}
    ND=K;
    for(int i=0;i<K-1;i++)
    {
        for(int j=i+1;j<K;j++)
        {
            bool flag=false;
            for(int k=0;k<M;k++) if((p(i)|p(j))==CM[k]) {flag=true;break;}
            if(flag) continue;
            D[ND]=p(i)|p(j);
            T[ND]=max(t[i],t[j]);
            ND++;
        }
    }
    for(int i=0;i<2*p(K);i++) {W[i]=INF;Dead[i]=false;}
    W[p(K)-1]=0;
    while(!Dead[p(K)])
    {
        int best=INF,b_ind;
        for(int i=0;i<2*p(K);i++) if((!Dead[i])&&(W[i]<best)) {best=W[i];b_ind=i;};
        if(best==INF)
        {
            printf("%d\n",-1);
            system("pause");
            return 0;
        }
        Dead[b_ind]=true;
        if(b_ind&p(K))                 // If boat is on the right side
        {
            for(int i=0;i<ND;i++) if((b_ind&D[i])==0)
            {
                if(good(b_ind^D[i])&&(W[b_ind]+T[i]<W[(b_ind^D[i])&(p(K)-1)]))
                {
                    W[(b_ind^D[i])&(p(K)-1)]=W[b_ind]+T[i];
                    //printf("%2x(%2d)->%2x(%2d) by %2x\n",b_ind,W[b_ind],(b_ind^D[i])&(p(K)-1),W[b_ind]+T[i],D[i]);
                }    
            }
        }
        else                           // If boat is on the left side
        {
            for(int i=0;i<ND;i++) if(((b_ind)&D[i])==D[i])
            {
                if(good((b_ind)^D[i])&&(W[b_ind]+T[i]<W[((b_ind)^D[i])|p(K)]))
                {
                    W[((b_ind)^D[i])|p(K)]=W[b_ind]+T[i];
                    //printf("%2x(%2d)->%2x(%2d) by %2x\n",b_ind,W[b_ind],(b_ind^D[i])|p(K),W[b_ind]+T[i],D[i]);
                }
            }
        }
        //printf("%x (%d)\n",b_ind,best);
    }
    //for(int i=0;i<2*p(K);i++) printf("%3x %3d\n",i,W[i]);
    printf("%d\n",W[p(K)]);
    return 0;
}
