#include<cstdio>
#include<cstring>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<vector>
#include<bitset>
#include<set>
#include<queue>
#include<stack>
#include<map>
#include<cstdlib>
#include<cmath>
#define PI 2*asin(1.0)
#define LL __int64
#define pb push_back
#define clr(a,b) memset(a,b,sizeof(a))
const int  MOD = 1e9 + 7;
const int N = 2e2 + 15;
const int INF = (1 << 30) - 1;
const int letter = 130;
using namespace std;
int main()
{
    int y,n,k;
    while(cin >> y >> k >> n)
    {
        if(y > n) {
                cout << -1 << endl;
                continue;
        }
        int flag = 0;
        for(int i = 1;i+y<=n;)
        {
            if((i+y)%k == 0)
            {
                flag = 1;
                cout << i <<" ";
                i += k;
            }
            else i++;
        }
        if(!flag) cout << -1;
        cout << endl;
    }
    return 0;
}


#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
long long int n,y,k,ptr;
cin>>y>>k>>>n;
long long int temp=n-y;
long long int flag=y%k;
ptr=k-flag;
if(y==n)
{
    printf("-1");
    return 0;
    }
    else
    {
while(ptr<=temp)
{
cout<<ptr<<" ";
ptr=ptr+k;
}
    }
return 0;
}


#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
long long int n,y,k,ptr;
scanf("%lld %lld %lld",&y,&k,&n);
long long int temp=n-y;
long long int flag=y%k;
ptr=k-flag;
if(y==n)
{
    printf("-1");
    return 0;
    }
    else
    {
while(ptr<=temp)
{
cout<<ptr<<" ";
ptr=ptr+k;
}
    }
return 0;
}


#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
long long int n,y,k,ptr;
cin>>y>>k>>n;
long long int temp=n-y;
long long int flag=y%k;
ptr=k-flag;
if(y==n)
{
    printf("-1");
    return 0;
    }
    if(flag==0 && temp<k)
    {
        printf("-1");
        return 0;
    }
    else
    {
while(ptr<=temp)
{
cout<<ptr<<" ";
ptr=ptr+k;
}
    }
return 0;
}


#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
long long int n,y,k,ptr;
cin>>y>>k>>n;
long long int temp=n-y;
long long int flag=y%k;
ptr=k-flag;
if(y==n)
{
    printf("-1");
    return 0;
    }
    if(temp<k)
    {
        printf("-1");
        return 0;
    }
    else
    {
while(ptr<=temp)
{
cout<<ptr<<" ";
ptr=ptr+k;
}
    }
return 0;
}


#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
long long int n,y,k,i;
scanf("%lld %lld %lld",&y,&k,&n);
long long int temp=n-y;
if(y==n)
{
printf("-1");
return 0;
}
else
{
for(i=1;i<=temp;i++)
{
if((y+i)%k==0)
break;
}
long long int ptr=i;
while(ptr<=temp)
{
cout<<ptr<<" ";
ptr=ptr+k;
}
}
return 0;
}


#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
long long int n,y,k,ptr;
cin>>y>>k>>n;
long long int temp=n-y;
long long int flag=n%k;
ptr=k-flag;
if(y==n)
{
    printf("-1");
    return 0;
    }
    else
    {
while(ptr<=temp)
{
cout<<ptr<<" ";
ptr=ptr+k;
}
    }
return 0;
}


#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
long long int n,y,k,ptr;
cin>>y>>k>>n;
long long int temp=n-y;
long long int flag=y%k;
ptr=k-flag;
if(y==n)
{
    printf("-1");
    return 0;
    }
    else
    {
while(ptr<=temp)
{
cout<<ptr<<" ";
ptr=ptr+k;
}
    }
return 0;
}


#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
long long int n,y,k,ptr;
cin>>y>>k>>n;
long long int temp=n-y;
long long int flag=y%k;
ptr=k-flag;
if(y==n)
{
    printf("-1");
    return 0;
    }
    if((flag+temp)<k)
    {
        printf("-1");
        return 0;
    }
    else
    {
while(ptr<=temp)
{
cout<<ptr<<" ";
ptr=ptr+k;
}
    }
return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <string>
#include <sstream>

#define MohammadAmin main()
#define ll long long int
#define MAX( A, B ) ( A > B ? A : B )

using namespace std;

int MohammadAmin{
    ll y, k, n;
    cin >> y >> k >> n;
    n -= n%k;
    ll x = n - y;
    if ( x < 1 ) {
        cout << -1;
        return 0;
    }
    for ( ll i = ( x%k == 0 ? k : x%k ); i <= x; i+=k ) {
        cout << i << " ";
    }
	return 0;
}


#include <bits/stdc++.h>
#define MAX 100005
#define MOD 1000000007
#define ll long long
using namespace std;

int rul[20][3];
int n, m ,k;
int arr[20];
ll dp[(1<<20)][20];
ll solve(ll m,ll p, ll mask){

//    if(dp[mask][m] != -1)return dp[mask][m];
    if(m == 0)return 0;

    ll ans = 0;

    for(int i = 0; i < n; i++){

        if((1<<i) & mask)continue;

        ll tt = solve(m - 1, i, mask ^ (1<<i)) + arr[i];

        ans = max(ans, tt);
        for(int j = 0; j < k; j++){

            if((p == rul[j][0] - 1) && (i == rul[j][1] - 1)){

                ans = max(ans, tt + rul[j][2]);
            }
        }
    }

    return dp[mask][m] = ans;

}

int main(){

    cin>>n>>m>>k;
    memset(&dp, -1, sizeof(dp));

    for(int i = 0; i < n; i++)cin>>arr[i];

    for(int i = 0; i < k; i++){

        cin>>rul[i][0]>>rul[i][1]>>rul[i][2];
    }

    cout<<solve(m,-1, 0)<<endl;

    return 0;
}


#include <bits/stdc++.h>
#define MAX 100005
#define MOD 1000000007
#define ll long long
using namespace std;

int rul[20][3];
int n, m ,k;
int arr[20];
ll fl[20] = {};
ll dp[20];
ll solve(ll m,ll fl[]){

    if(dp[m] != -1)return dp[m];

    if(m <= 0){

        return 0;
    }

    ll res = 0, ind = -1;
    for(int i = 0; i < k; i++){

        if(fl[rul[i][0] - 1] == 0 && fl[rul[i][1] - 1] == 0 && m > 1){

            ll tt = rul[i][2] + arr[rul[i][0] - 1] + arr[rul[i][1] - 1];

            fl[rul[i][0] - 1] = 1; fl[rul[i][1] - 1] = 1;
            ll x = solve(m - 2, fl);
            fl[rul[i][0] - 1] = 0; fl[rul[i][1] - 1] = 0;
            if(x + tt > res){

                ind = i;
                res = x + tt;
            }

        }
    }

    if(ind == -1){

        for(int i = 0; i < n; i++){

            if(fl[i] == 0){

                if(arr[i] > res){
                    res = arr[i];
                    ind = i;
                }
            }
        }
        fl[ind] = 1;
        res += solve(m - 1, fl);
    }else{

    fl[rul[ind][0] - 1] = 1; fl[rul[ind][1] - 1] = 1;

    }
    return dp[m] = res;

}

int main(){

    cin>>n>>m>>k;
    memset(&dp, -1, sizeof(dp));

    for(int i = 0; i < n; i++)cin>>arr[i];

    for(int i = 0; i < k; i++){

        cin>>rul[i][0]>>rul[i][1]>>rul[i][2];
    }

    cout<<solve(m,fl)<<endl;

    return 0;
}


#include <bits/stdc++.h>
#define MAX 100005
#define MOD 1000000007
#define ll long long
using namespace std;

int rul[20][3];
int n, m ,k;
int arr[20];
ll dp[(1<<20)][20];
ll solve(ll m,ll p, ll mask){

   if(dp[mask][p] != -1)return dp[mask][p];
    if(m == 0)return 0;

    ll ans = 0;

    for(int i = 0; i < n; i++){

        if((1<<i) & mask)continue;

        ll tt = solve(m - 1, i, mask ^ (1<<i)) + arr[i];

        ans = max(ans, tt);
        for(int j = 0; j < k; j++){

            if((p == rul[j][0] - 1) && (i == rul[j][1] - 1)){

                ans = max(ans, tt + rul[j][2]);
            }
        }

    }

    return dp[mask][p] = ans;

}

int main(){

    cin>>n>>m>>k;
    memset(&dp, -1, sizeof(dp));

    for(int i = 0; i < n; i++)cin>>arr[i];

    for(int i = 0; i < k; i++){

        cin>>rul[i][0]>>rul[i][1]>>rul[i][2];
    }

    cout<<solve(m,20, 0)<<endl;

    return 0;
}


#include <bits/stdc++.h>
#define MAX 100005
#define MOD 1000000007
#define ll long long
using namespace std;

int rul[25][20];
int n, m ,k;
int arr[25];
ll dp[(1<<20)][20];
ll solve(ll m,ll p, ll mask){

   if(dp[mask][p] != -1)return dp[mask][p];
    if(m <= 0)return 0;

    ll ans = 0;

    for(int i = 0; i < n; i++){

        if((1<<i) & mask)continue;

        ll tt = solve(m - 1, i, mask ^ (1<<i)) + arr[i];

        ans = max(ans, tt);
        for(int j = 0; j < k; j++){

            if((p == rul[j][0] - 1) && (i == rul[j][1] - 1)){

                ans = max(ans, tt + rul[j][2]);
            }
        }

    }

    return dp[mask][p] = ans;

}

int main(){

    cin>>n>>m>>k;
    memset(&dp, -1, sizeof(dp));
    memset(&arr, 0, sizeof(arr));
    memset(&rul, 0, sizeof(rul));

    for(int i = 0; i < n; i++)cin>>arr[i];

    for(int i = 0; i < k; i++){

        cin>>rul[i][0]>>rul[i][1]>>rul[i][2];
    }

    cout<<solve(m,20, 0)<<endl;

    return 0;
}


#include <bits/stdc++.h>
#define MAX 100005
#define MOD 1000000007
#define ll long long
using namespace std;

int rul[20][3];
int n, m ,k;
int arr[20];
ll dp[(1<<21)][20];
ll solve(ll m,ll p, ll mask){

   if(dp[mask][p] != -1)return dp[mask][p];
    if(m == 0)return 0;

    ll ans = 0;

    for(int i = 0; i < n; i++){

        if((1<<i) & mask)continue;

        ll tt = solve(m - 1, i, mask ^ (1<<i)) + arr[i];

        ans = max(ans, tt);
        for(int j = 0; j < k; j++){

            if((p == rul[j][0] - 1) && (i == rul[j][1] - 1)){

                ans = max(ans, tt + rul[j][2]);
            }
        }

    }

    return dp[mask][p] = ans;

}

int main(){

    cin>>n>>m>>k;
    memset(&dp, -1, sizeof(dp));

    for(int i = 0; i < n; i++)cin>>arr[i];

    for(int i = 0; i < k; i++){

        cin>>rul[i][0]>>rul[i][1]>>rul[i][2];
    }

    cout<<solve(m,20, 0)<<endl;

    return 0;
}


#include <bits/stdc++.h>
#define MAX 100005
#define MOD 1000000007
#define ll long long
using namespace std;

int rul[20][3];
int n, m ,k;
int arr[20];
ll dp[(1<<20)][20];
ll solve(ll m,ll p, ll mask){

   if(dp[mask][p] != -1)return dp[mask][p];
    if(m <= 0)return 0;

    ll ans = 0;

    for(int i = 0; i < n; i++){

        if((1<<i) & mask)continue;

        ll tt = solve(m - 1, i, mask ^ (1<<i)) + arr[i];

        ans = max(ans, tt);
        for(int j = 0; j < k; j++){

            if((p == rul[j][0] - 1) && (i == rul[j][1] - 1)){

                ans = max(ans, tt + rul[j][2]);
            }
        }

    }

    return dp[mask][p] = ans;

}

int main(){

    cin>>n>>m>>k;
    memset(&dp, -1, sizeof(dp));

    for(int i = 0; i < n; i++)cin>>arr[i];

    for(int i = 0; i < k; i++){

        cin>>rul[i][0]>>rul[i][1]>>rul[i][2];
    }

    cout<<solve(m,20, 0)<<endl;

    return 0;
}


#include <bits/stdc++.h>
#define MAX 100005
#define MOD 1000000007
#define ll long long
using namespace std;

int rul[20][3];
int n, m ,k;
int arr[20];
ll fl[20] = {};
ll dp[20];
ll solve(ll m,ll fl[]){

//
//    if(dp[m] != -1){
//        cout<<2<<endl;
//        return dp[m];
//
//    }

    if(m <= 0){

        return 0;
    }

    ll res = 0, ind = -1;
    for(int i = 0; i < k; i++){

        if(fl[rul[i][0] - 1] == 0 && fl[rul[i][1] - 1] == 0 && m > 1){

            ll tt = rul[i][2] + arr[rul[i][0] - 1] + arr[rul[i][1] - 1];

            fl[rul[i][0] - 1] = 1; fl[rul[i][1] - 1] = 1;
            ll x = solve(m - 2, fl);
            fl[rul[i][0] - 1] = 0; fl[rul[i][1] - 1] = 0;
            if(x + tt >= res){

                ind = i;
                res = x + tt;
            }

        }
    }

    int f = 0;

    for(int i = 0; i < n; i++){

            if(fl[i] == 0 && m > 0){

                fl[i] = 1;
                ll x = solve(m - 1, fl);
                fl[i] = 0;
                if(x + arr[i] >= res){
                    res = x + arr[i];
                    f = 1;
                    ind = i;
                }
            }
        }

  // cout<<res<<endl;
    return dp[m] = res;

}

int main(){

    cin>>n>>m>>k;
    memset(&dp, -1, sizeof(dp));

    for(int i = 0; i < n; i++)cin>>arr[i];

    for(int i = 0; i < k; i++){

        cin>>rul[i][0]>>rul[i][1]>>rul[i][2];
    }

    cout<<solve(m,fl)<<endl;

    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define read freopen("in.in","r",stdin)
#define write freopen("out.out","w",stdout)
#define FastIO ios::sync_with_stdio(0)
#define mod 1000000007
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
const int N = 20;
const int m1 = 0x5555555555555555; //binary: 0101...
const int m2 = 0x3333333333333333; //binary: 00110011..
const int m4 = 0x0f0f0f0f0f0f0f0f; //binary:  4 zeros,  4 ones ...
const int m8 = 0x00ff00ff00ff00ff; //binary:  8 zeros,  8 ones ...
const int m16 = 0x0000ffff0000ffff; //binary: 16 zeros, 16 ones ...
const int h01 = 0x0101010101010101; //the sum of 256 to the power of 0,1,2,3..
int n, m, k, sat[N], c[N][N];
int memo[N][N][300000];

int popcount64a(int x)
{
	x = (x & m1) + ((x >> 1) & m1); //put count of each  2 bits into those  2 bits
	x = (x & m2) + ((x >> 2) & m2); //put count of each  4 bits into those  4 bits
	x = (x & m4) + ((x >> 4) & m4); //put count of each  8 bits into those  8 bits
	x = (x & m8) + ((x >> 8) & m8); //put count of each 16 bits into those 16 bits
	x = (x & m16) + ((x >> 16) & m16); //put count of each 32 bits into those 32 bits
	return x;
}

int  dp(int idx, int last, int vis) {
	if (popcount64a(vis) == m) return 0;
	if (idx > n)return -mod;
	int ret = memo[idx][last][vis];
	if (ret != -1)return ret;
	int c1, c2 = 0;
	c1=dp(idx + 1, last, vis);
	if (!((1 << idx - 1)&vis)) {
		c2 = dp(1, idx, vis | (1 << idx - 1)) + sat[idx] + c[last][idx];
	}
	return ret = max(c1, c2);
}
int main() {
	FastIO;
#ifndef ONLINE_JUDGE
	read; write;
#endif
	cin >> n >> m >> k;
	for (int i = 1; i <=n; i++)
		cin >> sat[i];
	//memset(c, 0, sizeof c);
	memset(memo, -1, sizeof memo);
	int a, b,q;
	for(int i=0;i<k;i++)
	{
		cin >> a >> b >> q;
		c[a][b] = q;
	}
	cout << dp(1, 0, 0) << endl;
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define read freopen("in.in","r",stdin)
#define write freopen("out.out","w",stdout)
#define FastIO ios::sync_with_stdio(0)
#define mod 1000000007
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
const int N = 20;
int n, m, k, sat[N], c[N][N], power[18];
ll memo[300000][N];
int BitCount( int u)
{
	int count = 0;
	while (u) {
		count++;
		u &= (u - 1);
	}
	return count;
}

int main() {
	FastIO;
#ifndef ONLINE_JUDGE
	read; write;
#endif
	cin >> n >> m >> k;
	for (int i = 1; i <= n; i++)
		cin >> sat[i];
	memset(memo, 0, sizeof memo);
	int a, b, q;
	for (int i = 0, p = 1; i < 18; i++, p *= 2)
		power[i] = p;
	for (int i = 0; i < k; i++)
	{
		cin >> a >> b >> q;
		c[a][b] = q;
	}

	for (int i = 1; i <= n; i++) memo[power[i - 1]][i] = sat[i];

	for (int mask = 0; mask < power[n]; mask++)
		for (int last = 1; last <= n; last++)
			if(mask&power[last-1])
			for (int idx = 1; idx <= n; idx++) {
				if (!(mask&power[idx - 1]))
					memo[mask | power[idx - 1]][idx] = max(memo[mask | power[idx - 1]][idx], memo[mask][last] + sat[idx] + c[last][idx]);
			}
	ll ans = 0;
	for (int i = 0; i < power[n]; i++)
		if (BitCount(i)==m)
			for (int j = 1; j <= n; j++)
				ans = max(ans, memo[i][j]);
	cout << ans << endl;
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define read freopen("in.in","r",stdin)
#define write freopen("out.out","w",stdout)
#define FastIO ios::sync_with_stdio(0)
#define mod 1000000007
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
const int N = 20;
int n, m, k, sat[N], c[N][N], power[18];
ll memo[262200][N];
int BitCount( int u)
{
	int count = 0;
	while (u) {
		count++;
		u &= (u - 1);
	}
	return count;
}

int main() {
	FastIO;
#ifndef ONLINE_JUDGE
	read; write;
#endif
	cin >> n >> m >> k;
	for (int i = 1; i <= n; i++)
		cin >> sat[i];
	memset(memo, 0, sizeof memo);
	int a, b, q;
	for (int i = 0, p = 1; i <=18; i++, p *= 2)
		power[i] = p;
	for (int i = 0; i < k; i++)
	{
		cin >> a >> b >> q;
		c[a][b] = q;
	}

	for (int i = 1; i <= n; i++) memo[power[i - 1]][i] = sat[i];

	for (int mask = 0; mask < power[n]; mask++)
		for (int last = 1; last <= n; last++)
			if(mask&power[last-1])
			for (int idx = 1; idx <= n; idx++) {
				if (!(mask&power[idx - 1]))
					memo[mask | power[idx - 1]][idx] = max(memo[mask | power[idx - 1]][idx], memo[mask][last] + sat[idx] + c[last][idx]);
			}
	ll ans = 0;
	for (int i = 0; i < power[n]; i++)
		if (BitCount(i)==m)
			for (int j = 1; j <= n; j++)
				ans = max(ans, memo[i][j]);
	cout << ans << endl;
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define read freopen("in.in","r",stdin)
#define write freopen("out.out","w",stdout)
#define FastIO ios::sync_with_stdio(0)
#define mod 1000000007
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
const int N = 20;
const uint64_t m1 = 0x5555555555555555; //binary: 0101...
const uint64_t m2 = 0x3333333333333333; //binary: 00110011..
const uint64_t m4 = 0x0f0f0f0f0f0f0f0f; //binary:  4 zeros,  4 ones ...
const uint64_t m8 = 0x00ff00ff00ff00ff; //binary:  8 zeros,  8 ones ...
const uint64_t m16 = 0x0000ffff0000ffff; //binary: 16 zeros, 16 ones ...
const uint64_t h01 = 0x0101010101010101; //the sum of 256 to the power of 0,1,2,3..
int n, m, k, sat[N], c[N][N];
int memo[N][N][300000];

int popcount64a(uint64_t x)
{
	x = (x & m1) + ((x >> 1) & m1); //put count of each  2 bits into those  2 bits
	x = (x & m2) + ((x >> 2) & m2); //put count of each  4 bits into those  4 bits
	x = (x & m4) + ((x >> 4) & m4); //put count of each  8 bits into those  8 bits
	x = (x & m8) + ((x >> 8) & m8); //put count of each 16 bits into those 16 bits
	x = (x & m16) + ((x >> 16) & m16); //put count of each 32 bits into those 32 bits
	return x;
}

int  dp(int idx, int last, int vis) {
	if (popcount64a(vis) == m) return 0;
	if (idx > n)return -mod;
	ll ret = memo[idx][last][vis];
	if (ret != -1)return ret;
	ll c1, c2 = 0;
	c1=dp(idx + 1, last, vis);
	if (!((1 << idx - 1)&vis)) {
		c2 = dp(1, idx, vis | (1 << idx - 1)) + sat[idx] + c[last][idx];
	}
	return ret = max(c1, c2);
}
int main() {
	FastIO;
#ifndef ONLINE_JUDGE
	read; write;
#endif
	cin >> n >> m >> k;
	for (int i = 1; i <=n; i++)
		cin >> sat[i];
	//memset(c, 0, sizeof c);
	memset(memo, -1, sizeof memo);
	int a, b,q;
	for(int i=0;i<k;i++)
	{
		cin >> a >> b >> q;
		c[a][b] = q;
	}
	cout << dp(1, 0, 0) << endl;
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define read freopen("in.in","r",stdin)
#define write freopen("out.out","w",stdout)
#define FastIO ios::sync_with_stdio(0)
#define mod 1000000007
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
const int N = 20;
const int m1 = 0x5555555555555555; //binary: 0101...
const int m2 = 0x3333333333333333; //binary: 00110011..
const int m4 = 0x0f0f0f0f0f0f0f0f; //binary:  4 zeros,  4 ones ...
const int m8 = 0x00ff00ff00ff00ff; //binary:  8 zeros,  8 ones ...
const int m16 = 0x0000ffff0000ffff; //binary: 16 zeros, 16 ones ...
const int h01 = 0x0101010101010101; //the sum of 256 to the power of 0,1,2,3..
int n, m, k, sat[N], c[N][N];
int memo[N][N][262200];
int popcount64a(int x)
{
	x = (x & m1) + ((x >> 1) & m1); //put count of each  2 bits into those  2 bits
	x = (x & m2) + ((x >> 2) & m2); //put count of each  4 bits into those  4 bits
	x = (x & m4) + ((x >> 4) & m4); //put count of each  8 bits into those  8 bits
	x = (x & m8) + ((x >> 8) & m8); //put count of each 16 bits into those 16 bits
	x = (x & m16) + ((x >> 16) & m16); //put count of each 32 bits into those 32 bits
	return x;
}

int  dp(int idx, int last, int vis) {
	if (popcount64a(vis) == m) return 0;
	if (idx > n)return -mod;
	int ret = memo[idx][last][vis];
	if (ret != -1)return ret;
	int c1, c2 = 0;
	c1=dp(idx + 1, last, vis);
	if (!((1 << idx - 1)&vis)) {
		c2 = dp(1, idx, vis | (1 << idx - 1)) + sat[idx] + c[last][idx];
	}
	return ret = max(c1, c2);
}
int main() {
	FastIO;
#ifndef ONLINE_JUDGE
	read; write;
#endif
	cin >> n >> m >> k;
	for (int i = 1; i <=n; i++)
		cin >> sat[i];
	//memset(c, 0, sizeof c);
	memset(memo, -1, sizeof memo);
	int a, b,q;
	for(int i=0;i<k;i++)
	{
		cin >> a >> b >> q;
		c[a][b] = q;
	}
	cout << dp(1, 0, 0) << endl;
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define read freopen("in.in","r",stdin)
#define write freopen("out.out","w",stdout)
#define FastIO ios::sync_with_stdio(0)
#define mod 1000000007
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
const int N = 20;
const uint64_t m1 = 0x5555555555555555; //binary: 0101...
const uint64_t m2 = 0x3333333333333333; //binary: 00110011..
const uint64_t m4 = 0x0f0f0f0f0f0f0f0f; //binary:  4 zeros,  4 ones ...
const uint64_t m8 = 0x00ff00ff00ff00ff; //binary:  8 zeros,  8 ones ...
const uint64_t m16 = 0x0000ffff0000ffff; //binary: 16 zeros, 16 ones ...
const uint64_t h01 = 0x0101010101010101; //the sum of 256 to the power of 0,1,2,3..
int n, m, k, sat[N], c[N][N];
ll memo[N][N][300000];

int popcount64a(uint64_t x)
{
	x = (x & m1) + ((x >> 1) & m1); //put count of each  2 bits into those  2 bits
	x = (x & m2) + ((x >> 2) & m2); //put count of each  4 bits into those  4 bits
	x = (x & m4) + ((x >> 4) & m4); //put count of each  8 bits into those  8 bits
	x = (x & m8) + ((x >> 8) & m8); //put count of each 16 bits into those 16 bits
	x = (x & m16) + ((x >> 16) & m16); //put count of each 32 bits into those 32 bits
	return x;
}

ll dp(int idx, int last, int vis) {
	if (popcount64a(vis) == m) return 0;
	if (idx > n)return -mod;
	ll ret = memo[idx][last][vis];
	if (ret != -1)return ret;
	ll c1, c2 = 0;
	c1=dp(idx + 1, last, vis);
	if (!((1 << idx - 1)&vis)) {
		c2 = dp(1, idx, vis | (1 << idx - 1)) + sat[idx] + c[last][idx];
	}
	return ret = max(c1, c2);
}
int main() {
	FastIO;
#ifndef ONLINE_JUDGE
	read; write;
#endif
	cin >> n >> m >> k;
	for (int i = 1; i <=n; i++)
		cin >> sat[i];
	//memset(c, 0, sizeof c);
	memset(memo, -1, sizeof memo);
	int a, b,q;
	for(int i=0;i<k;i++)
	{
		cin >> a >> b >> q;
		c[a][b] = q;
	}
	cout << dp(1, 0, 0) << endl;
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define read freopen("in.in","r",stdin)
#define write freopen("out.out","w",stdout)
#define FastIO ios::sync_with_stdio(0)
#define mod 1000000007
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
const int N = 20;
int n, m, k, sat[N], c[N][N];
int memo[N][N][262200];
int BitCount(unsigned int u)
{
	unsigned int uCount;

	uCount = u - ((u >> 1) & 033333333333) - ((u >> 2) & 011111111111);
	return ((uCount + (uCount >> 3)) & 030707070707) % 63;
}
int  dp(int idx, int last, int vis) {
	if (BitCount(vis) == m) return 0;
	if (idx > n)return -mod;
	int ret = memo[idx][last][vis];
	if (ret != -1)return ret;
	int c1, c2 = 0;
	c1=dp(idx + 1, last, vis);
	if (!((1 << idx - 1)&vis)) {
		c2 = dp(1, idx, vis | (1 << idx - 1)) + sat[idx] + c[last][idx];
	}
	return ret = max(c1, c2);
}
int main() {
	FastIO;
#ifndef ONLINE_JUDGE
	read; write;
#endif
	cin >> n >> m >> k;
	for (int i = 1; i <=n; i++)
		cin >> sat[i];
	//memset(c, 0, sizeof c);
	memset(memo, -1, sizeof memo);
	int a, b,q;
	for(int i=0;i<k;i++)
	{
		cin >> a >> b >> q;
		c[a][b] = q;
	}
	cout << dp(1, 0, 0) << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 1 << 20;

int n, m, k;
int a[20], comb[20][20];
LL dp[N][20];

int cnt(int state) {
	int num = 0;
	for (int i = 0; i < n; ++i)
		if (state & (1 << i))
			num++;
	return num;
}

int main() {
	while (~scanf("%d%d%d", &n, &m, &k)) {
		for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
		memset(comb, 0, sizeof(comb));
		memset(dp, 0, sizeof(dp));
		while (k--) {
			int x, y, c;
			scanf("%d%d%d", &x, &y, &c);
			comb[x - 1][y - 1] = c;
		}

		int ed = (1 << n);
		LL ans = 0;
		for (int state = 0; state < ed; ++state)
			for (int i = 0; i < n; ++i)
				if (state & (1 << i)) {
					dp[state][i] = 1LL * a[i];
					for (int j = i + 1; j < n; ++j)
						if (state & (1 << j)) {
							dp[state][j] = a[j];
							dp[state][i] = max(dp[state][i], dp[state ^ (1 << i)][j] + 1LL * comb[j][i] + 1LL * a[i]);
						}
					if (cnt(state) == m) ans = max(ans, dp[state][i]);
				}
		printf("%lld\n", ans);
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

int n, m, k, a[20], r[20][20];
LL dp[1000000][20];

int main() {
	scanf("%d%d%d", &n, &m, &k);
	for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
	while (k--) {
		int x, y, c;
		scanf("%d%d%d", &x, &y, &c);
		r[x - 1][y - 1] = c;
	}
	LL ans = 0;
	for (int st = 0; st < (1 << n); ++st)
		for (int i = 0; i < n; ++i) {
			if ((st >> i) & 1) {
				dp[st][i] = a[i];
				for (int j = 0; j < n; ++j)
					if (j != i && (st >> j) & 1)
						dp[st][i] = max(dp[st][i], dp[st ^ (1 << i)][j] + a[i] + r[j][i]);
			}
			int cnt = 0;
			for (int j = 0; j < n; ++j)
				if ((st >> j) & 1)
					cnt++;
			if (cnt == m)
				ans = max(ans, dp[st][i]);
		}
	printf("%lld\n", ans);
	return 0;
}


/*
 给出n个点的值，让你选m个点，依次连成一条线，
 两点连成的边若满足给出的k条建边的规则，就加上边权。
 求以何种顺序选取m个点连成线，可以使权和最大。
 dp[st][i]:表示在st状态下，且选取点i时的最大权和
*/
#include <bits/stdc++.h>
using namespace std;
const int N = (1 << 18) + 5;
typedef long long LL;

int a[20];
int comb[20][20];
LL dp[N][20], ans;
int n, m, k;

int cnt(int st) {
	int res = 0;
	for (int i = 0; i < n; ++i)
		if ((st & (1 << i))) res++;
	return res;
}

int main() {
	while (~scanf("%d%d%d", &n, &m, &k)) {
		memset(comb, 0, sizeof(comb));
		for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
		for (int i = 0; i < k; ++i) {
			int x, y, c;
			scanf("%d%d%d", &x, &y, &c);
			comb[--x][--y] = c;
		}
		ans = 0;
		int ed = (1 << n);
		memset(dp, 0, sizeof(dp));
		for (int st = 0; st < ed; ++st)
			for (int i = 0; i < n; ++i) {
				if (st & (1 << i)) {
					dp[st][i] = a[i];
					for (int j = 0; j < n; ++j)
						if (i != j && (st & (1 << j))) {
							//has = true;   // 如果建边的话就更新, j → i建边,且不选 i 才能建边
							dp[st][i] = max(dp[st][i], dp[st ^ (1 << i)][j] + a[i] + comb[j][i]);
						}
					//if (!has) dp[st][i] = a[i]; // 只选一个点,就是点权
				}
				if (cnt(st) == m) ans = max(ans, dp[st][i]);
			}
		printf("%lld\n", ans);
	}
	return 0;
}


/*
 给出n个点的值，让你选m个点，依次连成一条线，
 两点连成的边若满足给出的k条建边的规则，就加上边权。
 求以何种顺序选取m个点连成线，可以使权和最大。
 dp[st][i]:表示在st状态下，且选取点i时的最大权和
*/
#include <bits/stdc++.h>
using namespace std;
const int N = (1 << 18) + 5;
typedef long long LL;

int a[20];
int comb[20][20];
LL dp[N][20], ans;
int n, m, k;

int cnt(int st) {
	int res = 0;
	for (int i = 0; i < n; ++i)
		if ((st & (1 << i))) res++;
	return res;
}

int main() {
	while (~scanf("%d%d%d", &n, &m, &k)) {
		memset(comb, 0, sizeof(comb));
		for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
		for (int i = 0; i < k; ++i) {
			int x, y, c;
			scanf("%d%d%d", &x, &y, &c);
			comb[--x][--y] = c;
		}
		ans = 0;
		int ed = (1 << n);
		memset(dp, 0, sizeof(dp));
		for (int st = 0; st < ed; ++st)
			for (int i = 0; i < n; ++i) {
				if (st & (1 << i)) {
					bool has = false;
					for (int j = 0; j < n; ++j)
						if (i != j && (st & (1 << j))) {
							has = true;   // 如果建边的话就更新, j → i建边,且不选 i 才能建边
							dp[st][i] = max(dp[st][i], dp[st ^ (1 << i)][j] + a[i] + comb[j][i]);
						}
					if (!has) dp[st][i] = a[i]; // 只选一个点,就是点权
				}
				if (cnt(st) == m) ans = max(ans, dp[st][i]);
			}
		printf("%lld\n", ans);
	}
	return 0;
}


/*
 给出n个点的值，让你选m个点，依次连成一条线，
 两点连成的边若满足给出的k条建边的规则，就加上边权。
 求以何种顺序选取m个点连成线，可以使权和最大。
 dp[st][i]:表示在st状态下，且选取点i时的最大权和
*/
#include <bits/stdc++.h>
using namespace std;
const int N = (1 << 18) + 5;
typedef long long LL;

int a[20];
int comb[20][20];
LL dp[N][20], ans;
int n, m, k;

int cnt(int st) {
	int res = 0;
	for (int i = 0; i < n; ++i)
		if ((st & (1 << i))) res++;
	return res;
}

int main() {
	while (~scanf("%d%d%d", &n, &m, &k)) {
		memset(comb, 0, sizeof(comb));
		for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
		for (int i = 0; i < k; ++i) {
			int x, y, c;
			scanf("%d%d%d", &x, &y, &c);
			comb[--x][--y] = c;
		}
		ans = 0;
		int ed = (1 << n);
		memset(dp, 0, sizeof(dp));
		for (int st = 0; st < ed; ++st)
			for (int i = 0; i < n; ++i) {
				if (st & (1 << i)) {
					bool has = false;
					for (int j = 0; j < n; ++j)
						if (i != j && (st & (1 << j))) {
							has = true;   // 如果建边的话就更新, j → i建边,且不选 i 才能建边
							dp[st][i] = max(dp[st][i], dp[st ^ (1 << i)][j] + a[i] + comb[j][i]);
						}
					if (!has) dp[st][i] = a[i]; // 只选一个点,就是点权
				}
				if (cnt(st) == m) ans = max(ans, dp[st][i]);
			}
		printf("%d\n", ans);
	}
	return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = (1 << 18) + 5;
typedef long long LL;

int n, m, k;
int a[20], comb[20][20];
LL dp[N][20], ans;

int cnt(int st) {
	int res = 0;
	for (int i = 0; i < n; ++i)
		if (st & (1 << i)) res++;
	return res;
}

int main() {
	while (~scanf("%d%d%d", &n, &m, &k)) {
		memset(comb, 0, sizeof(comb));
		memset(dp, 0, sizeof(dp));
		for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
		for (int i = 1; i <= k; ++i) {
			int x, y, c;
			scanf("%d%d%d", &x, &y, &c);
			comb[--x][--y] = c;
		}
		ans = 0;
		for (int st = 0; st < (1 << n); ++st) {
			for (int i = 0; i < n; ++i) {
				if (st & (1 << i)) {
					dp[st][i] = a[i];
					for (int j = 0; j < n; ++j) {
						if (i != j && st & (1 << j)) {
							dp[st][i] = max(dp[st][i], dp[st ^ (1 << j)][i] + a[j] + comb[i][j]);
						}
					}
				}
				if (cnt(st) == m) ans = max(ans, dp[st][i]);
			}
		}
		printf("%lld\n", ans);
	}
	return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = (1 << 18) + 5;
typedef long long LL;

int n, m, k;
int a[20], comb[20][20];
LL dp[N][20], ans;

int cnt(int st) {
	int res = 0;
	for (int i = 0; i < n; ++i)
		if (st & (1 << i)) res++;
	return res;
}

int main() {
	while (~scanf("%d%d%d", &n, &m, &k)) {
		memset(comb, 0, sizeof(comb));
		memset(dp, 0, sizeof(dp));
		for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
		for (int i = 1; i <= k; ++i) {
			int x, y, c;
			scanf("%d%d%d", &x, &y, &c);
			comb[--x][--y] = c;
		}
		ans = 0;
		for (int st = 0; st < (1 << n); ++st) {
			for (int i = 0; i < n; ++i) {
				if (st & (1 << i)) {
					dp[st][i] = a[i];
					for (int j = 0; j < n; ++j) {
						if (i != j && st & (1 << j)) {
							dp[st][i] = max(dp[st][i], dp[st ^ (1 << i)][j] + a[i] + comb[j][i]);
						}
					}
				}
				if (cnt(st) == m) ans = max(ans, dp[st][i]);
			}
		}
		printf("%lld\n", ans);
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 1 << 20;

int n, m, k;
int a[20], comb[20][20];
LL dp[N][20];

int cnt(int state) {
	int num = 0;
	for (int i = 0; i < n; ++i)
		if (state & (1 << i))
			num++;
	return num;
}

int main() {
	while (~scanf("%d%d%d", &n, &m, &k)) {
		for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
		memset(comb, 0, sizeof(comb));
		memset(dp, 0, sizeof(dp));
		while (k--) {
			int x, y, c;
			scanf("%d%d%d", &x, &y, &c);
			comb[x - 1][y - 1] = c;
		}

		int ed = (1 << n);
		LL ans = 0;
		for (int state = 0; state < ed; ++state)
			for (int i = 0; i < n; ++i)
				if (state & (1 << i)) {
					dp[state][i] = 1LL * a[i];
					for (int j = i + 1; j < n; ++j)
						if (state & (1 << j))
							dp[state][i] = max(dp[state][i], dp[state ^ (1 << i)][j] + 1LL * comb[j][i] + 1LL * a[i]);
					if (cnt(state) == m) ans = max(ans, dp[state][i]);
				}
		printf("%lld\n", ans);
	}
	return 0;
}


#include "bits/stdc++.h"
using namespace std;

#define ll long long int
#define MAX 1 << 18

int n, m, k;
int a[20];
int sat[20][20];
ll dp[20][MAX + 1];

ll solve(int prev, int rem, int mask)
{
    if(rem == 0)
        return 0;
    if(dp[prev][mask] != -1)
        return dp[prev][mask];
    ll ans = 0;
    for(int i = 1 ; i <= n ; i++)
    {
        if(mask & (1 << i))
             continue;
        ans = max(ans, a[i] + sat[i][prev] + solve(i, rem - 1, mask | (1 << i)));
    }
    return dp[prev][mask] = ans;
}

int main()
{
    scanf("%d %d %d", &n, &m, &k);
    for(int i = 1 ; i <= n ; i++)
        scanf("%d", &a[i]);
    for(int i = 1 ; i <= k ; i++)
    {
        int x, y, c;
        scanf("%d %d %d", &x, &y, &c);
        sat[x][y] = c;
    }
    memset(dp, -1, sizeof(dp));
    printf("%lld", solve(0, m, 0));
    return 0;
}


#include "bits/stdc++.h"
using namespace std;

#define ll long long int
#define MAX 1 << 18

int n, m, k;
int a[20];
int sat[20][20];
unordered_map < pair < int , pair < int , int > >, ll > dp;

ll solve(int prev, int rem, int mask)
{
    if(rem == 0)
        return 0;
    if(dp.count({prev, {rem, mask}}))
        return dp[{prev, {rem, mask}}];
    ll ans = 0;
    for(int i = 1 ; i <= n ; i++)
    {
        if(mask & (1 << i))
             continue;
        ans = max(ans, a[i] + sat[i][prev] + solve(i, rem - 1, mask | (1 << i)));
    }
    return dp[{prev, {rem, mask}}] = ans;
}

int main()
{
    scanf("%d %d %d", &n, &m, &k);
    for(int i = 1 ; i <= n ; i++)
        scanf("%d", &a[i]);
    for(int i = 1 ; i <= k ; i++)
    {
        int x, y, c;
        scanf("%d %d %d", &x, &y, &c);
        sat[x][y] = c;
    }
    printf("%lld", solve(0, m, 0));
    return 0;
}


#include "bits/stdc++.h"
using namespace std;

#define ll long long int
#define MAX 1 << 18

int n, m, k;
int a[20];
int sat[20][20];
map < pair < int , pair < int , int > >, int > dp;

ll solve(int prev, int rem, int mask)
{
    if(rem == 0)
        return 0;
    if(dp.count({prev, {rem, mask}}))
        return dp[{prev, {rem, mask}}];
    ll ans = 0;
    for(int i = 1 ; i <= n ; i++)
    {
        if(mask & (1 << i))
             continue;
        ans = max(ans, a[i] + sat[i][prev] + solve(i, rem - 1, mask | (1 << i)));
    }
    return dp[{prev, {rem, mask}}] = ans;
}

int main()
{
    scanf("%d %d %d", &n, &m, &k);
    for(int i = 1 ; i <= n ; i++)
        scanf("%d", &a[i]);
    for(int i = 1 ; i <= k ; i++)
    {
        int x, y, c;
        scanf("%d %d %d", &x, &y, &c);
        sat[x][y] = c;
    }
    printf("%lld", solve(0, m, 0));
    return 0;
}


#include "bits/stdc++.h"
using namespace std;

#define ll long long int
#define MAX 1 << 18

int n, m, k;
int a[20];
int sat[20][20];
ll dp[20][MAX + 1];

ll solve(int prev, int mask)
{
    if(__builtin_popcount(mask) == m)
        return 0;
    if(dp[prev][mask] != -1)
        return dp[prev][mask];
    ll ans = 0;
    for(int i = 1 ; i <= n ; i++)
    {
        if(mask & (1 << i))
             continue;
        ans = max(ans, a[i] + sat[i][prev] + solve(i, mask | (1 << i)));
    }
    return dp[prev][mask] = ans;
}

int main()
{
    scanf("%d %d %d", &n, &m, &k);
    for(int i = 1 ; i <= n ; i++)
        scanf("%d", &a[i]);
    for(int i = 1 ; i <= k ; i++)
    {
        int x, y, c;
        scanf("%d %d %d", &x, &y, &c);
        sat[x][y] = c;
    }
    memset(dp, -1, sizeof(dp));
    printf("%lld", solve(0, 0));
    return 0;
}


#include "bits/stdc++.h"
using namespace std;

#define ll long long int
#define MAX 1 << 18

int n, m, k;
int a[20];
int sat[20][20];
ll dp[19][19][MAX + 1];

ll solve(int prev, int rem, int mask)
{
    if(rem == 0)
        return 0;
    if(dp[prev][rem][mask] != -1)
        return dp[prev][rem][mask];
    ll ans = 0;
    for(int i = 1 ; i <= n ; i++)
    {
        if(mask & (1 << i))
             continue;
        ans = max(ans, a[i] + sat[i][prev] + solve(i, rem - 1, mask | (1 << i)));
    }
    return dp[prev][rem][mask] = ans;
}

int main()
{
    scanf("%d %d %d", &n, &m, &k);
    for(int i = 1 ; i <= n ; i++)
        scanf("%d", &a[i]);
    for(int i = 1 ; i <= k ; i++)
    {
        int x, y, c;
        scanf("%d %d %d", &x, &y, &c);
        sat[x][y] = c;
    }
    memset(dp, -1, sizeof(dp));
    printf("%lld", solve(0, m, 0));
    return 0;
}


#include "bits/stdc++.h"
using namespace std;

#define ll long long int
#define MAX 1 << 18

int n, m, k;
int a[20];
int sat[20][20];
map < pair < int , pair < int , int > >, ll > dp;

ll solve(int prev, int rem, int mask)
{
    if(rem == 0)
        return 0;
    if(dp.count({prev, {rem, mask}}))
        return dp[{prev, {rem, mask}}];
    ll ans = 0;
    for(int i = 1 ; i <= n ; i++)
    {
        if(mask & (1 << i))
             continue;
        ans = max(ans, a[i] + sat[i][prev] + solve(i, rem - 1, mask | (1 << i)));
    }
    return dp[{prev, {rem, mask}}] = ans;
}

int main()
{
    scanf("%d %d %d", &n, &m, &k);
    for(int i = 1 ; i <= n ; i++)
        scanf("%d", &a[i]);
    for(int i = 1 ; i <= k ; i++)
    {
        int x, y, c;
        scanf("%d %d %d", &x, &y, &c);
        sat[x][y] = c;
    }
    printf("%lld", solve(0, m, 0));
    return 0;
}


/*#include<bits/stdc++.h>

using namespace std;
const long long A=100000000000000LL, N = 1228228;
long long mask, i, j, m, n, k, a[N], b[N], x, y, z, c[21][21], ans, ot, dp[N][21];
long long len(long long mask){
    long long k = 0;
    for (int i = 0; i < n; i++)if(mask&b[i])k++;
    return k;
}
int main(){
    //freopen("test.inp", "r", stdin);
    //freopen("test.out", "w", stdout);
    cin>>m>>n>>k;
    for(int i=0; i<n; i++)scanf("%d", &a[i]);

    b[0]=1;
	for(i=1;i<=n;i++)b[i]=b[i-1]*2;

    while(k--){
        scanf("%d%d%d", &x, &y, &z), c[x-1][y-1] = z;
    }

    for (int i = 0; i < n; i++){
        dp[b[i]][i] = a[i];
    }

    for(mask = 0; mask < (1<<n); mask++){
        for (i = 0; i < n; i++){
            if(mask & b[i]){
                for (j = 0; j < n; j++){
                    if((mask & b[j]) == 0){
                        dp[(mask|b[j])][j] = max(dp[(mask|b[j])][j], dp[mask][i]+c[i][j]+a[j]);
                    }
                }
            }
        }
    }

    for (mask = 0; mask <(1<<n); mask++){
        if(len(mask)==m){
            for(i = 0; i < n; i++){
                ans = max(ans, dp[mask][i]);
            }
        }
    }

    cout<<ans<<endl;

}*/

#include<bits/stdc++.h>

using namespace std;
const long long A=100000000000000LL,N=1228228;

long long mask,i,j,n,m,k,a[N],b[N],x,y,z,c[21][21],o,dp[N][21];

long long len(long long mask){
	long long k=0;
	for(i=0;i<n;i++)if(mask&b[i])k++;
	return k;
}

int main(){
    //freopen("test.inp", "r", stdin);
    //freopen("test.out", "w", stdout);

	cin>>n>>m>>k;
	for(i=0;i<n;i++)scanf("%d",&a[i]);

	b[0]=1;
	for(i=1;i<=n;i++)b[i]=b[i-1]*2;
	b[n] = (1<<n);

	while(k--)scanf("%d%d%d",&x,&y,&z),c[x-1][y-1]=z;

	for(i=0;i<n;i++)dp[b[i]][i]=a[i];

	for(mask=0;mask<(1<<n);mask++)
        for(i=0;i<n;i++)
            if(mask&b[i]){
                for(j=0;j<n;j++)
                    if((mask&b[j])==0)
                        dp[(mask|b[j])][j]=max(dp[(mask|b[j])][j],dp[mask][i]+c[i][j]+a[j]);
            }

	for(mask=0;mask<(1<<n);mask++)
        if(len(mask)==m)
            for(i=0;i<n;i++)
                o=max(o,dp[mask][i]);

	cout<<o<<"\n";
}


#include<bits/stdc++.h>

using namespace std;
const long long A=100000000000000LL, N = 1228228;
long long mask, i, j, m, n, k, a[N], b[N], x, y, z, c[21][21], ans, ot, dp[N][21];
long long len(long long mask){
    long long k = 0;
    for (int i = 0; i < n; i++)if(mask&b[i])k++;
    return k;
}
int main(){
    //freopen("test.inp", "r", stdin);
    //freopen("test.out", "w", stdout);
    cin>>m>>n>>k;
    for(int i=0; i<n; i++)scanf("%d", &a[i]);

    b[0]=1;
	for(i=1;i<=n;i++)b[i]=b[i-1]*2;

    while(k--){
        scanf("%d%d%d", &x, &y, &z), c[x-1][y-1] = z;
    }

    for (int i = 0; i < n; i++){
        dp[b[i]][i] = a[i];
    }

    for(mask = 0; mask < (1<<n); mask++){
        for (i = 0; i < n; i++){
            if(mask & b[i]){
                for (j = 0; j < n; j++){
                    if((mask & b[j]) == 0){
                        dp[(mask|b[j])][j] = max(dp[(mask|b[j])][j], dp[mask][i]+c[i][j]+a[j]);
                    }
                }
            }
        }
    }

    for (mask = 0; mask <(1<<n); mask++){
        if(len(mask)==m){
            for(i = 0; i < n; i++){
                ans = max(ans, dp[mask][i]);
            }
        }
    }

    cout<<ans<<endl;

}


#include <bits/stdc++.h>

#define F first
#define S second
#define MP make_pair

using namespace std;

const int N = 1024*1024, NN = 25;
long long int dp[N], pw[NN], a[NN];
map<pair<long long int, long long int>, long long int>mp;
bool b[N];

int main () {
    pw[0]=1;
    for(int i = 1 ; i < 20 ; i++ )pw[i]=pw[i-1]*2;
    long long int n, m, k;
    cin >> n >> m >> k;
    for(int i = 0 ; i < n ; i++)cin>>a[i];
    for(int i = 0 ; i < k ; i ++ ) {
        long long int a1, b, c;
        cin >> a1 >> b >> c;
        a1--;
        b--;
        mp[MP(a1,b)]=c;
    }
    for(int i = 0 ; i < n ; i++ ) {
        for(int j = 0 ; j < n ; j++ ) {
            if(i==j)continue;
            dp[pw[i]+pw[j]]=a[i]+a[j]+mp[MP(i,j)];
            b[pw[i]+pw[j]]=1;
        }
        b[pw[i]]=1;
    }
    b[0]=1;
    for(int j = 0 ; j < pw[n] ; j++) {
        if(!b[j]) {
            vector<int>bi;
            bi.clear();
            for(int i = 0 ; i < 20 ; i++ ) {
                if(pw[i]&j)bi.push_back(i);
            }
            for(int u: bi) {
                for(int u2: bi) {
                    if(u==u2)continue;
                    dp[j]=max(dp[j],dp[j-pw[u]]+a[u]+mp[MP(u,u2)]);
                }
            }
        }
    }
    long long int ans =0;
    for(int i = 0 ; i < pw[n] ; i++ ) {
        long long int i1=i, t=0;
        while(i1) {
            t+=(i1&1);
            i1/=2;
        }
        if(t==m)ans=max(ans,dp[i]);
    }
    cout << ans << '\n';
}


#include <bits/stdc++.h>

#define F first
#define S second
#define MP make_pair

using namespace std;

const int N = 1024*1024, NN = 25;
long long int dp[N], pw[NN], a[NN];
map<pair<long long int, long long int>, long long int>mp;
bool b[N];

int main () {
    pw[0]=1;
    for(int i = 1 ; i < 20 ; i++ )pw[i]=pw[i-1]*2;
    long long int n, m, k;
    cin >> n >> m >> k;
    for(int i = 0 ; i < n ; i++)cin>>a[i];
    for(int i = 0 ; i < k ; i ++ ) {
        long long int a1, b, c;
        cin >> a1 >> b >> c;
        a1--;
        b--;
        mp[MP(a1,b)]=c;
    }
    if(m==1) return cout << *max_element(a,a+n),0;
    for(int i = 0 ; i < n ; i++ ) {
        for(int j = 0 ; j < n ; j++ ) {
            if(i==j)continue;
            dp[pw[i]+pw[j]]=a[i]+a[j]+mp[MP(i,j)];
            b[pw[i]+pw[j]]=1;
        }
        b[pw[i]]=1;
    }
    b[0]=1;
    for(int j = 0 ; j < pw[n] ; j++) {
        if(!b[j]) {
            vector<int>bi;
            bi.clear();
            for(int i = 0 ; i < 20 ; i++ ) {
                if(pw[i]&j)bi.push_back(i);
            }
            for(int u: bi) {
                for(int u2: bi) {
                    if(u==u2)continue;
                    dp[j]=max(dp[j],dp[j-pw[u]]+a[u]+mp[MP(u,u2)]);
                }
            }
        }
    }
    long long int ans =0;
    for(int i = 0 ; i < pw[n] ; i++ ) {
        long long int i1=i, t=0;
        while(i1) {
            t+=(i1&1);
            i1/=2;
        }
        if(t==m)ans=max(ans,dp[i]);
    }
    cout << ans << '\n';
}


#include <bits/stdc++.h>

#define F first
#define S second
#define MP make_pair

using namespace std;

const int N = 1024*1024, NN = 25;
long long int dp[N][NN], pw[NN], a[NN];
map<pair<long long int, long long int>, long long int>mp;
bool b[N][NN];

int main () {
    pw[0]=1;
    for(int i = 1 ; i < 20 ; i++ )pw[i]=pw[i-1]*2;
    long long int n, m, k;
    cin >> n >> m >> k;
    for(int i = 0 ; i < n ; i++)cin>>a[i];
    for(int i = 0 ; i < k ; i ++ ) {
        long long int a1, b, c;
        cin >> a1 >> b >> c;
        a1--;
        b--;
        mp[MP(a1,b)]=c;
    }
    if(m==1) return cout << *max_element(a,a+n),0;
    for(int i = 0 ; i < n ; i++) {
        dp[pw[i]][i]=a[i];
    }
    for(int i = 1 ; i < pw[n] ; i++ ) {
        for(int j = 0 ; j < n ; j++ ) {
            if(pw[j]&i) {
                for(int t = 0 ; t < n ; t++ ) {
                    if(!(pw[t]&i)) {
                        dp[i+pw[t]][t]=max(dp[i+pw[t]][t],dp[i][j]+a[t]+mp[MP(j,t)]);
                    }
                }
            }
        }
    }
    long long int ans = 0;
    for(int i = 1 ; i < pw[n] ; i++ ) {
        long long int t = i, o=0;
        while(t) {
            o+=t&1;
            t/=2;
        }
        if(o==m) {
            ans=max(ans,*max_element(dp[i],dp[i]+20));
        }
    }
    cout << ans;
}


#include <bits/stdc++.h>

#define F first
#define S second
#define MP make_pair

using namespace std;

const int N = 1024*1024, NN = 25;
long long int dp[N], pw[NN], a[NN];
map<pair<long long int, long long int>, long long int>mp;
bool b[N];

int main () {
    pw[0]=1;
    for(int i = 1 ; i < 20 ; i++ )pw[i]=pw[i-1]*2;
    long long int n, m, k;
    cin >> n >> m >> k;
    for(int i = 0 ; i < n ; i++)cin>>a[i];
    for(int i = 0 ; i < k ; i ++ ) {
        long long int a1, b, c;
        cin >> a1 >> b >> c;
        a1--;
        b--;
        mp[MP(a1,b)]=c;
    }
    if(m==1) return cout << *max_element(a,a+n),0;
    for(int i = 0 ; i < n ; i++ ) {
        for(int j = 0 ; j < n ; j++ ) {
            if(i==j)continue;
            dp[pw[i]+pw[j]]=a[i]+a[j]+max(mp[MP(i,j)],mp[MP(j,i)]);
            b[pw[i]+pw[j]]=1;
        }
        b[pw[i]]=1;
    }
    b[0]=1;
    for(int j = 0 ; j < pw[n] ; j++) {
        if(!b[j]) {
            vector<int>bi;
            bi.clear();
            for(int i = 0 ; i < 20 ; i++ ) {
                if(pw[i]&j)bi.push_back(i);
            }
            for(int u: bi) {
                for(int u2: bi) {
                    if(u==u2)continue;
                    dp[j]=max(dp[j],dp[j-pw[u]]+a[u]+mp[MP(u,u2)]);
                }
            }
        }
    }
    long long int ans =0;
    for(int i = 0 ; i < pw[n] ; i++ ) {
        long long int i1=i, t=0;
        while(i1) {
            t+=(i1&1);
            i1/=2;
        }
        if(t==m)ans=max(ans,dp[i]);
    }
    cout << ans << '\n';
}


#include <bits/stdc++.h>

#define F first
#define S second
#define MP make_pair

using namespace std;

const int N = 1024*1024, NN = 25;
long long int dp[N], pw[NN], a[NN];
map<pair<long long int, long long int>, long long int>mp;
bool b[N];

int main () {
    pw[0]=1;
    for(int i = 1 ; i < 20 ; i++ )pw[i]=pw[i-1]*2;
    long long int n, m, k;
    cin >> n >> m >> k;
    for(int i = 0 ; i < n ; i++)cin>>a[i];
    for(int i = 0 ; i < k ; i ++ ) {
        long long int a1, b, c;
        cin >> a1 >> b >> c;
        a1--;
        b--;
        mp[MP(a1,b)]=c;
    }
    if(m==1) return cout << *max_element(a,a+n),0;
    for(int i = 0 ; i < n ; i++ ) {
        for(int j = 0 ; j < n ; j++ ) {
            if(i==j)continue;
            dp[pw[i]+pw[j]]=max(a[i]+a[j]+mp[MP(i,j)],dp[pw[i]+pw[j]]);
            b[pw[i]+pw[j]]=1;
        }
        b[pw[i]]=1;
    }
    b[0]=1;
    for(int j = 0 ; j < pw[n] ; j++) {
        if(!b[j]) {
            vector<int>bi;
            bi.clear();
            for(int i = 0 ; i < 20 ; i++ ) {
                if(pw[i]&j)bi.push_back(i);
            }
            for(int u: bi) {
                for(int u2: bi) {
                    if(u==u2)continue;
                    dp[j]=max(dp[j],dp[j-pw[u]]+a[u]+mp[MP(u,u2)]);
                }
            }
        }
        b[j]=1;
        cout << bitset<6>(j) <<  ' ' << dp[j] << '\n';
    }
    long long int ans =0;
    for(int i = 0 ; i < pw[n] ; i++ ) {
        long long int i1=i, t=0;
        while(i1) {
            t+=(i1&1);
            i1/=2;
        }
        if(t==m)ans=max(ans,dp[i]);
    }
    cout << ans << '\n';
}


#include <bits/stdc++.h>

#define F first
#define S second
#define MP make_pair

using namespace std;

const int N = 1024*1024, NN = 25;
long long int dp[N][NN], pw[NN], a[NN];
map<pair<long long int, long long int>, long long int>mp;
bool b[N][NN];

int main () {
    pw[0]=1;
    for(int i = 1 ; i < 20 ; i++ )pw[i]=pw[i-1]*2;
    long long int n, m, k;
    cin >> n >> m >> k;
    for(int i = 0 ; i < n ; i++)cin>>a[i];
    for(int i = 0 ; i < k ; i ++ ) {
        long long int a1, b, c;
        cin >> a1 >> b >> c;
        a1--;
        b--;
        mp[MP(a1,b)]=c;
    }
    if(m==1) return cout << *max_element(a,a+n),0;
    for(int i = 0 ; i < n ; i++) {
        dp[pw[i]][i]=a[i];
    }
    for(int i = 1 ; i < pw[n] ; i++ ) {
        for(int j = 0 ; j < n ; j++ ) {
            if(pw[j]&i) {
                for(int t = 0 ; t < n ; t++ ) {
                    if(!(pw[t]&i)) {
                        dp[i+pw[t]][t]=max(dp[i+pw[t]][t],dp[i][j]+a[t]+mp[MP(j,t)]);
                    }
                }
            }
        }
    }//
    long long int ans = 0;
    for(int i = 1 ; i < pw[n] ; i++ ) {
        long long int t = i, o=0;
        while(t) {
            o+=t&1;
            t/=2;
        }
        if(o==m) {
            ans=max(ans,*max_element(dp[i],dp[i]+20));
        }
    }
    cout << ans;
}


#include <bits/stdc++.h>

#define F first
#define S second
#define MP make_pair

using namespace std;

const int N = 1024*1024, NN = 25;
long long int dp[N], pw[NN], a[NN];
map<pair<long long int, long long int>, long long int>mp;
bool b[N];

int main () {
    pw[0]=1;
    for(int i = 1 ; i < 20 ; i++ )pw[i]=pw[i-1]*2;
    long long int n, m, k;
    cin >> n >> m >> k;
    for(int i = 0 ; i < n ; i++)cin>>a[i];
    for(int i = 0 ; i < k ; i ++ ) {
        long long int a1, b, c;
        cin >> a1 >> b >> c;
        a1--;
        b--;
        mp[MP(a1,b)]=c;
    }
    if(m==1) return cout << *max_element(a,a+n),0;
    for(int i = 0 ; i < n ; i++ ) {
        for(int j = 0 ; j < n ; j++ ) {
            if(i==j)continue;
            dp[pw[i]+pw[j]]=max(a[i]+a[j]+mp[MP(i,j)],dp[pw[i]+pw[j]]);
            b[pw[i]+pw[j]]=1;
        }
        b[pw[i]]=1;
    }
    b[0]=1;
    for(int j = 0 ; j < pw[n] ; j++) {
        if(!b[j]) {
            vector<int>bi;
            bi.clear();
            for(int i = 0 ; i < 20 ; i++ ) {
                if(pw[i]&j)bi.push_back(i);
            }
            for(int u: bi) {
                for(int u2: bi) {
                    if(u==u2)continue;
                    dp[j]=max(dp[j],dp[j-pw[u]]+a[u]+mp[MP(u,u2)]);
                }
            }
        }
        b[j]=1;
        //cout << bitset<6>(j) <<  ' ' << dp[j] << '\n';
    }
    long long int ans =0;
    for(int i = 0 ; i < pw[n] ; i++ ) {
        long long int i1=i, t=0;
        while(i1) {
            t+=(i1&1);
            i1/=2;
        }
        if(t==m)ans=max(ans,dp[i]);
    }
    cout << ans << '\n';
}


#include <iostream>
using namespace std;
typedef long long int lli;
int a[18] = {};
int r[18][18] = {};
int n=0;

lli func(int used, int m, int l){
    if(m==0){
        return 0;
    }

    lli res=0;
    for(int i=0; i<n; i++){
        if( ((1<<i)&used) == 0 ) {
            lli tmp = func(used|(1 << i), m - 1, i) + a[i] + r[l][i];
            if (tmp > res) res = tmp;
        }
    }
    return res;
}

int main(){
    int m,k;

    cin>>n>>m>>k;

    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    for(int i=0; i<k; i++){
        int f,g;
        cin>>f>>g;
        cin>>r[f-1][g-1];
    }

    lli res=0;
    for(int i=0; i<n; i++){
        lli tmp = func((1<<i), m-1, i)+a[i];
        if (tmp>res) res=tmp;
    }

    cout<<res;
    return 0;
}


#include <iostream>

using namespace std;
typedef unsigned long long int ulli;
int n, m, k;
int dish[18]={};
int rule[17][18]={};
ulli dp[1<<18];

ulli max(ulli a, ulli b){
    return a>b?a:b;
}

ulli eat(int mask, int last, int cnt){
    if (cnt == 0) return 0;
    ///todo: if exist in dp[mask][last] return it's  value
    if(dp[mask]!=0) return dp[mask];

    ulli _max=0;
    for(int i=0; i<n; i++){
        if( ((1<<i) & mask) == 0){
            _max = max(eat( ((1<<i)|mask), i, cnt-1)+dish[i]+rule[last][i], _max);
        }
    }
    dp[mask]==_max;
    return _max;
}

int main() {
    cin >> n >> m >> k;
    for (int i = 0; i < n; i++) {
        cin >> dish[i];
    }
    for (int i = 0; i < k; i++) {
        int a, b;
        cin >> a >> b;
        cin >> rule[a-1][b-1];
    }
    ulli res=0;
    for (int i = 0; i < 18; i++) {
        res = max(eat(0|(1<<i), i, m-1)+dish[i], res);
    }
    cout<<res;
    return 0;
}


#include <iostream>
#include <fstream>
#include <cstring>

int n ,m, k;
int *dish;
int **rule;

long long defined[(1<<19)][19];

void r_f_i(){
	std::cin>>n>>m>>k;
  dish = new int[n];
  for(int i=0; i<n; i++){
	  std::cin>>dish[i];
  }

  rule = new int*[n];
  for(int i=0; i<n; i++){
	rule[i] = new int[n];
  }
  for(int i=0; i<n; i++){
	  for(int j=0; j<n; j++){
		rule[i][j]=0;
	  }
  }
  for(int i=0; i<k; i++){
	int j,k;
	std::cin >> j >> k;
	std::cin >> rule[j-1][k-1];
  }

}

void show(){
std::cout<<n<<" "<<m<<" "<<k<<"\n";
  for(int i=0; i<n; i++){
	  std::cout<<dish[i]<<" ";
  }
  std::cout<<"\n";
  for(int i=0; i<n; i++){
	  for(int j=0; j<n; j++){
	  	std::cout<<rule[i][j]<<" ";
	  }
	  std::cout<<"\n";
  }
}

void del(){
  delete[] dish;
  for (int i=0; i < n; i++){
	 delete[] rule[i];
  }
  delete[] rule;
}

long long max(int dish_n, int mask, int count){
	if (count == m) return 0;
	long long &res = defined[mask][dish_n];
	if (res>-1) return res;
	for (int i=0; i<n; i++){
		if ((mask & (1<<i)) == 0){
		long long tmp = max(i, mask|(1<<i), count+1)+dish[i]+rule[dish_n][i];
		if (res < tmp) res = tmp;
		}
	}

return res;
}

int main(){
r_f_i();
//show();
memset(defined, -1, sizeof(defined));
int mask = 0;
long long res = 0;
for (int i=0; i<n; i++){
	long long tmp = max(i, mask|(1<<i), 1)+dish[i];
	if (res<tmp) res = tmp;
}
std::cout<<res;

del();
return 0;
}


#include <iostream>
//#include <ctime>

using namespace std;
typedef unsigned long long int ulli;
int n, m, k;
int dish[18];
int rule[17][18]={};
ulli dp[1<<18]={};

ulli max(ulli a, ulli b){
    return a>b?a:b;
}

ulli eat(int mask, int last, int cnt){
    if (cnt == 0) return 0;
    ///todo: if exist in dp[mask][last] return it's  value
    ulli & _max = dp[mask];
    if(_max!=0) return dp[mask];

    for(int i=0; i<n; i++){
        if( ((1<<i) & mask) == 0){
            _max = max(eat( ((1<<i)|mask), i, cnt-1)+dish[i]+rule[last][i], _max);
        }
    }
    dp[mask]==_max;
    return _max;
}

int main() {
    cin >> n >> m >> k;
    for (int i = 0; i < n; i++) {
        cin >> dish[i];
    }
    for (int i = 0; i < k; i++) {
        int a, b;
        cin >> a >> b;
        cin >> rule[a-1][b-1];
    }

 //   std::clock_t start;
 //   double duration;

 //   start = std::clock();

    ulli res=0;
    for (int i = 0; i < 18; i++) {
        res = max(eat(0|(1<<i), i, m-1)+dish[i], res);
    }
  //  duration = ( std::clock() - start ) / (double) CLOCKS_PER_SEC;
    cout<<res;
    return 0;
}


#include <iostream>
using namespace std;
typedef long long int lli;
int a[18] = {};
int r[18][18] = {};
int n=0;

lli dp[18][(1<<18)] = {-1};

lli func(int used, int m, int l){
    if(m==0){
        return 0;
    }
    if(dp[l][used]>-1) return dp[l][used];
    lli res=0;
    for(int i=0; i<n; i++){
        if( ((1<<i)&used) == 0 ) {
            lli tmp = func(used|(1 << i), m - 1, i) + a[i] + r[l][i];
            if (tmp > res) res = tmp;
        }
    }
    dp[l][used] = res;
    return res;
}

int main(){
    int m,k;

    cin>>n>>m>>k;

    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    for(int i=0; i<k; i++){
        int f,g;
        cin>>f>>g;
        cin>>r[f-1][g-1];
    }

    lli res=0;
    for(int i=0; i<n; i++){
        lli tmp = func((1<<i), m-1, i)+a[i];
        if (tmp>res) res=tmp;
    }

    cout<<res;
    return 0;
}


#include <iostream>
#include <cstring>
using namespace std;
typedef long long int lli;
int a[18] = {};
int r[18][18] = {};
int n=0;
lli dp[18][(1<<18)];

lli func(int used, int m, int l){
    if(m==0){
        return 0;
    }
    if(dp[l][used]>-1) return dp[l][used];
    lli res=0;
    for(int i=0; i<n; i++){
        if( ((1<<i)&used) == 0 ) {
            lli tmp = func(used|(1 << i), m - 1, i) + a[i] + r[l][i];
            if (tmp > res) res = tmp;
        }
    }
    dp[l][used] = res;
    return res;
}

int main(){
    memset(dp,-1,sizeof(dp));
    int m,k;

    cin>>n>>m>>k;

    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    for(int i=0; i<k; i++){
        int f,g;
        cin>>f>>g;
        cin>>r[f-1][g-1];
    }

    lli res=0;
    for(int i=0; i<n; i++){
        lli tmp = func((1<<i), m-1, i)+a[i];
        if (tmp>res) res=tmp;
    }

    cout<<res;
    return 0;
}


#include <iostream>
#include <fstream>

int n ,m, k;
long long *dish;
long long **rule;

void r_f_i(){
	std::cin>>n>>m>>k;
  dish = new int[n];
  for(int i=0; i<n; i++){
	  std::cin>>dish[i];
  }

  rule = new int*[n];
  for(int i=0; i<n; i++){
	rule[i] = new int[n];
  }
  for(int i=0; i<n; i++){
	  for(int j=0; j<n; j++){
		rule[i][j]=0;
	  }
  }
  for(int i=0; i<k; i++){
	int j,k;
	std::cin >> j >> k;
	std::cin >> rule[j-1][k-1];
  }

}

void r_f_f(const char* file){
  std::ifstream f;
  f.open(file);
  f>>n>>m>>k;

  dish = new int[n];
  for(int i=0; i<n; i++){
	f>>dish[i];
  }

  rule = new int*[n];
  for(int i=0; i<n; i++){
	rule[i] = new int[n];
  }
  for(int i=0; i<n; i++){
	  for(int j=0; j<n; j++){
		rule[i][j]=0;
	  }
  }
  for(int i=0; i<k; i++){
	int j,k;
	f >> j >> k;
	f >> rule[j-1][k-1];
  }

}

void show(){
std::cout<<n<<" "<<m<<" "<<k<<"\n";
  for(int i=0; i<n; i++){
	  std::cout<<dish[i]<<" ";
  }
  std::cout<<"\n";
  for(int i=0; i<n; i++){
	  for(int j=0; j<n; j++){
	  	std::cout<<rule[i][j]<<" ";
	  }
	  std::cout<<"\n";
  }
}

void del(){
  delete[] dish;
  for (int i=0; i < n; i++){
	 delete[] rule[i];
  }
  delete[] rule;
}

long long max(int dish_n, int mask, int count){
	if (count == m) return 0;
	long long res = 0;
	for (int i=0; i<n; i++){
		if ((mask & (1<<i)) == 0){
		long long tmp = max(i, mask|(1<<i), count+1)+dish[i]+rule[dish_n][i];
		if (res < tmp) res = tmp;
		}
	}

return res;
}

int main(){
r_f_i();
//show();

int mask = 0;
long long res = 0;
for (int i=0; i<n; i++){
	long long tmp = max(i, mask|(1<<i), 1)+dish[i];
	if (res<tmp) res = tmp;
}
std::cout<<res;

del();
return 0;
}


#include <iostream>
#include <fstream>

int n ,m, k;
int *dish;
int **rule;

void r_f_i(){
	std::cin>>n>>m>>k;
  dish = new int[n];
  for(int i=0; i<n; i++){
	  std::cin>>dish[i];
  }

  rule = new int*[n];
  for(int i=0; i<n; i++){
	rule[i] = new int[n];
  }
  for(int i=0; i<n; i++){
	  for(int j=0; j<n; j++){
		rule[i][j]=0;
	  }
  }
  for(int i=0; i<k; i++){
	int j,k;
	std::cin >> j >> k;
	std::cin >> rule[j-1][k-1];
  }

}

void r_f_f(const char* file){
  std::ifstream f;
  f.open(file);
  f>>n>>m>>k;

  dish = new int[n];
  for(int i=0; i<n; i++){
	f>>dish[i];
  }

  rule = new int*[n];
  for(int i=0; i<n; i++){
	rule[i] = new int[n];
  }
  for(int i=0; i<n; i++){
	  for(int j=0; j<n; j++){
		rule[i][j]=0;
	  }
  }
  for(int i=0; i<k; i++){
	int j,k;
	f >> j >> k;
	f >> rule[j-1][k-1];
  }

}

void show(){
std::cout<<n<<" "<<m<<" "<<k<<"\n";
  for(int i=0; i<n; i++){
	  std::cout<<dish[i]<<" ";
  }
  std::cout<<"\n";
  for(int i=0; i<n; i++){
	  for(int j=0; j<n; j++){
	  	std::cout<<rule[i][j]<<" ";
	  }
	  std::cout<<"\n";
  }
}

void del(){
  delete[] dish;
  for (int i=0; i < n; i++){
	 delete[] rule[i];
  }
  delete[] rule;
}

int max(int dish_n, int mask, int count){
	if (count == m) return 0;
	int res = 0;
	for (int i=0; i<n; i++){
		if ((mask & (1<<i)) == 0){
		int tmp = max(i, mask|(1<<i), count+1)+dish[i]+rule[dish_n][i];
		if (res < tmp) res = tmp;
		}
	}

return res;
}

int main(){
r_f_i();
//show();

int mask = 0;
int res = 0;
for (int i=0; i<n; i++){
	int tmp = max(i, mask|(1<<i), 1)+dish[i];
	if (res<tmp) res = tmp;
}
std::cout<<res;

del();
return 0;
}


#include <iostream>

using namespace std;
typedef unsigned long long int ulli;
int n, m, k;
int dish[18];
int rule[18][18]={};
ulli dp[1<<18][18]={};

ulli max(ulli a, ulli b){
    return a>b?a:b;
}

ulli eat(int mask, int last, int cnt){
    if (cnt == 0) return 0;
    ///todo: if exist in dp[mask][last] return it's  value
    ulli & _max = dp[mask][last];
    if(_max!=0) return _max;

    for(int i=0; i<n; i++){
        if( ((1<<i) & mask) == 0){
            _max = max(eat( ((1<<i)|mask), i, cnt-1)+dish[i]+rule[last][i], _max);
        }
    }
    return _max;
}

int main() {
    cin >> n >> m >> k;
    for (int i = 0; i < n; i++) {
        cin >> dish[i];
    }
    for (int i = 0; i < k; i++) {
        int a, b;
        cin >> a >> b;
        cin >> rule[a-1][b-1];
    }

    ulli res=0;
    for (int i = 0; i < 18; i++) {
        res = max(eat(0|(1<<i), i, m-1)+dish[i], res);
    }
    cout<<res;
    return 0;
}


#include <iostream>
#include <fstream>

int n ,m, k;
long long *dish;
long long **rule;

void r_f_i(){
	std::cin>>n>>m>>k;
  dish = new long long[n];
  for(int i=0; i<n; i++){
	  std::cin>>dish[i];
  }

  rule = new long long*[n];
  for(int i=0; i<n; i++){
	rule[i] = new long long[n];
  }
  for(int i=0; i<n; i++){
	  for(int j=0; j<n; j++){
		rule[i][j]=0;
	  }
  }
  for(int i=0; i<k; i++){
	int j,k;
	std::cin >> j >> k;
	std::cin >> rule[j-1][k-1];
  }

}

void show(){
std::cout<<n<<" "<<m<<" "<<k<<"\n";
  for(int i=0; i<n; i++){
	  std::cout<<dish[i]<<" ";
  }
  std::cout<<"\n";
  for(int i=0; i<n; i++){
	  for(int j=0; j<n; j++){
	  	std::cout<<rule[i][j]<<" ";
	  }
	  std::cout<<"\n";
  }
}

void del(){
  delete[] dish;
  for (int i=0; i < n; i++){
	 delete[] rule[i];
  }
  delete[] rule;
}

long long max(int dish_n, int mask, int count){
	if (count == m) return 0;
	long long res = 0;
	for (int i=0; i<n; i++){
		if ((mask & (1<<i)) == 0){
		long long tmp = max(i, mask|(1<<i), count+1)+dish[i]+rule[dish_n][i];
		if (res < tmp) res = tmp;
		}
	}

return res;
}

int main(){
r_f_i();
//show();

int mask = 0;
long long res = 0;
for (int i=0; i<n; i++){
	long long tmp = max(i, mask|(1<<i), 1)+dish[i];
	if (res<tmp) res = tmp;
}
std::cout<<res;

del();
return 0;
}


#include <iostream>
#include <fstream>

int n ,m, k;
long long *dish;
long long **rule;

long long defined[(1<<19)][19];

void r_f_i(){
	std::cin>>n>>m>>k;
  dish = new long long[n];
  for(int i=0; i<n; i++){
	  std::cin>>dish[i];
  }

  rule = new long long*[n];
  for(int i=0; i<n; i++){
	rule[i] = new long long[n];
  }
  for(int i=0; i<n; i++){
	  for(int j=0; j<n; j++){
		rule[i][j]=0;
	  }
  }
  for(int i=0; i<k; i++){
	int j,k;
	std::cin >> j >> k;
	std::cin >> rule[j-1][k-1];
  }

}

void show(){
std::cout<<n<<" "<<m<<" "<<k<<"\n";
  for(int i=0; i<n; i++){
	  std::cout<<dish[i]<<" ";
  }
  std::cout<<"\n";
  for(int i=0; i<n; i++){
	  for(int j=0; j<n; j++){
	  	std::cout<<rule[i][j]<<" ";
	  }
	  std::cout<<"\n";
  }
}

void del(){
  delete[] dish;
  for (int i=0; i < n; i++){
	 delete[] rule[i];
  }
  delete[] rule;
}

long long max(int dish_n, int mask, int count){
	if (count == m) return 0;
	long long &res = defined[mask][dish_n];
	if (res>0) return res;
	for (int i=0; i<n; i++){
		if ((mask & (1<<i)) == 0){
		long long tmp = max(i, mask|(1<<i), count+1)+dish[i]+rule[dish_n][i];
		if (res < tmp) res = tmp;
		}
	}

return res;
}

int main(){
r_f_i();
//show();

int mask = 0;
long long res = 0;
for (int i=0; i<n; i++){
	long long tmp = max(i, mask|(1<<i), 1)+dish[i];
	if (res<tmp) res = tmp;
}
std::cout<<res;

del();
return 0;
}


#include <iostream>
using namespace std;
typedef long long int lli;
int a[18] = {};
int r[18][18] = {};
int n=0;

lli dp[18][(1<<18)] = {};

lli func(int used, int m, int l){
    if(m==0){
        return 0;
    }
    if(dp[l][used]>0) return dp[l][used];
    lli res=0;
    for(int i=0; i<n; i++){
        if( ((1<<i)&used) == 0 ) {
            lli tmp = func(used|(1 << i), m - 1, i) + a[i] + r[l][i];
            if (tmp > res) res = tmp;
        }
    }
    dp[l][used] = res;
    return res;
}

int main(){
    int m,k;

    cin>>n>>m>>k;

    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    for(int i=0; i<k; i++){
        int f,g;
        cin>>f>>g;
        cin>>r[f-1][g-1];
    }

    lli res=0;
    for(int i=0; i<n; i++){
        lli tmp = func((1<<i), m-1, i)+a[i];
        if (tmp>res) res=tmp;
    }

    cout<<res;
    return 0;
}


#include <iostream>
using namespace std;
int a[18] = {};
int r[18][18] = {};
int n=0;

int func(int used, int m, int l){
    if(m==0){
        return 0;
    }

    int res=0;
    for(int i=0; i<n; i++){
        if( ((1<<i)&used) == 0 ) {
            int tmp = func(used|(1 << i), m - 1, i) + a[i] + r[l][i];
            if (tmp > res) res = tmp;
        }
    }
    return res;
}

int main(){
    int m,k;

    cin>>n>>m>>k;

    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    for(int i=0; i<k; i++){
        int f,g;
        cin>>f>>g;
        cin>>r[f-1][g-1];
    }

    int res=0;
    for(int i=0; i<n; i++){
        int tmp = func((1<<i), m-1, i)+a[i];
        if (tmp>res) res=tmp;
    }

    cout<<res;
    return 0;
}


#include<iostream>
#include<stack>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<ctime>
#include<math.h>
#include<functional>
#include<cstring>
#include<iomanip>
#include<set>
#include<utility>
#include<limits.h>
#include<stdio.h>
#define lowbit(x) (x)&(-x)

typedef long long ll;
//状压dp题，本来是想回溯找到所有大小为m的集合，但是找到后不知道如何才能让羁绊凑得最大
using namespace std;
const int maxn = 10 + 10;
const int maxm = 2e5 + 10;
const ll mod = 1e9+7;
const int inf = 0x3ffffff;
const double eps = 1e-5;
/*ll gcd(ll a, ll b)//最大公约数
{
	return b == 0 ? a : gcd(b, a%b);
}
ll lcm(ll a, ll b)
{
	return a / gcd(a, b)*b;
}
ll fast_pow(ll a, ll k)//快速幂
{
	ll ans = 1;
	a = a%mod;
	while (k != 0)
	{
		if (k & 1) ans = (ans*a) % mod;
			k >>= 1;
		a = (a*a) % mod;
	}
	return ans;
}
ll C(ll n, ll m)//组合数的计算
{
	ll ans = 1;
	for (ll i = 1;i <= m;i++)
		ans = (ans*(n - m + i) / i) % mod;
	return ans%mod;
}

bool is_prime(ll x)//素数判断
{
	if (x == 2 || x == 3) return true;
	if (x % 6 != 1 && x % 6 != 5) return false;
	ll temp = sqrt(1.0*x);
	for (ll i = 5;i <= temp;i += 6)
		if (x%i == 0 || x % (i + 2) == 0) return false;
	return true;
}
int prime[maxm], pnum = 0;//素数表，pnum是索引
bool p[maxm] = { 0 };//如果被筛掉，就为true
void Find_Prime()//更快的筛选法，遇到一个素数，就把它的倍数全部筛掉
{
	for (int i = 2;i < maxm;i++)
	{
		if (p[i] == false)//不用一个数一个数的判断素数了
		{
			prime[pnum++] = i;
			for (int j = i + i;j < maxm;j += i)//筛掉素数的倍数
				p[j] = true;
		}
	}
}

void Exgcd(ll a, ll b, ll &x, ll &y) {
if (!b) x = 1, y = 0;
else Exgcd(b, a % b, y, x), y -= a / b * x;
}//x是a在mod b下的逆元
ll CRT(int a[],int m[],int n)
{
ll M=1,ans=0,t,x,y;
for(int i=0; i<n; i++)
{
M*=m[i];///M为除数乘积
}
for(int i=0; i<n; i++)
{
t=M/m[i];///除了mi以外的n-1个整数乘积
Exgcd(t,m[i],x,y);///求逆元，由扩展欧几里得转换成t*ti+m[i]*y=1来求ti
ans=(ans+a[i]*x*t)%M;
}
return (ans+M)%M;
}*/

ll n, m, k, ans;
ll a[20], ad[20][20], f[(1 << 18) + 5][20];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cin >> n >> m >> k;
	for (int i = 0;i < n;i++)
		cin >> a[i];
	for (int i = 0;i < k;i++)
	{
		int x, y, z;
		cin >> x >> y >> z;
		ad[x - 1][y - 1] = z;
	}
	for (int i = 0;i < n;i++)
		f[(1 << i)][i] = a[i];
	for (int now = 0;now < (1 << n);now++)
	{
		int cnt = 0;
		for(int i=0;i<n;i++)
			if (now&(1 << i))
			{
				++cnt;
				for (int j = 0;j < n;j++)
					if (!(now&(1 << j)))
						f[now | (1 << j)][j] = max(f[now | (1 << j)][j], f[now][i] + a[j] + ad[i][j]);
			}
		if (cnt == m)
			for (int i = 0;i < n;i++)
				if(now&&(1<<i))
					ans = max(ans, f[now][i]);

	}
	cout << ans;
	return ~~(0 - 0);
}


#include<iostream>
#include<stack>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<ctime>
#include<math.h>
#include<functional>
#include<cstring>
#include<iomanip>
#include<set>
#include<utility>
#include<limits.h>
#include<stdio.h>
#define lowbit(x) (x)&(-x)

typedef long long ll;
//状压dp题，本来是想回溯找到所有大小为m的集合，但是找到后不知道如何才能让羁绊凑得最大
using namespace std;
const int maxn = 10 + 10;
const int maxm = 2e5 + 10;
const ll mod = 1e9+7;
const int inf = 0x3ffffff;
const double eps = 1e-5;
/*ll gcd(ll a, ll b)//最大公约数
{
	return b == 0 ? a : gcd(b, a%b);
}
ll lcm(ll a, ll b)
{
	return a / gcd(a, b)*b;
}
ll fast_pow(ll a, ll k)//快速幂
{
	ll ans = 1;
	a = a%mod;
	while (k != 0)
	{
		if (k & 1) ans = (ans*a) % mod;
			k >>= 1;
		a = (a*a) % mod;
	}
	return ans;
}
ll C(ll n, ll m)//组合数的计算
{
	ll ans = 1;
	for (ll i = 1;i <= m;i++)
		ans = (ans*(n - m + i) / i) % mod;
	return ans%mod;
}

bool is_prime(ll x)//素数判断
{
	if (x == 2 || x == 3) return true;
	if (x % 6 != 1 && x % 6 != 5) return false;
	ll temp = sqrt(1.0*x);
	for (ll i = 5;i <= temp;i += 6)
		if (x%i == 0 || x % (i + 2) == 0) return false;
	return true;
}
int prime[maxm], pnum = 0;//素数表，pnum是索引
bool p[maxm] = { 0 };//如果被筛掉，就为true
void Find_Prime()//更快的筛选法，遇到一个素数，就把它的倍数全部筛掉
{
	for (int i = 2;i < maxm;i++)
	{
		if (p[i] == false)//不用一个数一个数的判断素数了
		{
			prime[pnum++] = i;
			for (int j = i + i;j < maxm;j += i)//筛掉素数的倍数
				p[j] = true;
		}
	}
}

void Exgcd(ll a, ll b, ll &x, ll &y) {
if (!b) x = 1, y = 0;
else Exgcd(b, a % b, y, x), y -= a / b * x;
}//x是a在mod b下的逆元
ll CRT(int a[],int m[],int n)
{
ll M=1,ans=0,t,x,y;
for(int i=0; i<n; i++)
{
M*=m[i];///M为除数乘积
}
for(int i=0; i<n; i++)
{
t=M/m[i];///除了mi以外的n-1个整数乘积
Exgcd(t,m[i],x,y);///求逆元，由扩展欧几里得转换成t*ti+m[i]*y=1来求ti
ans=(ans+a[i]*x*t)%M;
}
return (ans+M)%M;
}*/

ll n, m, k, ans;
ll a[20], ad[20][20], f[(1 << 18) + 5][20];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cin >> n >> m >> k;
	for (int i = 0;i < n;i++)
		cin >> a[i];
	for (int i = 0;i < k;i++)
	{
		int x, y, z;
		cin >> x >> y >> z;
		ad[x - 1][y - 1] = z;
	}
	for (int i = 0;i < n;i++)
		f[1 << i][i] = a[i];//先吃一个，满意度为a[i]
	for (int now = 0;now < (1 << n);++now)//枚举状态
	{
		int cnt = 0;//计算已经吃了几道菜
		for (int i = 0;i < n;i++)
		{
			if (now&(1 << i))//枚举吃的最后一道菜
			{
				++cnt;
				for (int j = 0;j < n;j++)//枚举接下来吃的那道菜
					if (!(now&(1 << j)))
						f[now | (1 << j)][j] = max(f[now | (1 << j)][j], f[now][i] + a[j] + ad[i][j]);
			}
		}
		if (cnt == m)
			for (int i = 0;i < n;i++)
				if (now&(1 << i)) ans = max(ans, f[now][i]);
	}
	cout << ans;
	return ~~(0 - 0);
}


#include<iostream>
#include<stack>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<ctime>
#include<math.h>
#include<functional>
#include<cstring>
#include<iomanip>
#include<set>
#include<utility>
#include<limits.h>
#include<stdio.h>
#define lowbit(x) (x)&(-x)

typedef long long ll;
//
using namespace std;
const int maxn = 9 + 10;
const int maxm = 2e5 + 10;
const ll mod = 1e9+7;
const int inf = 0x3ffffff;
const double eps = 1e-5;
/*ll gcd(ll a, ll b)//最大公约数
{
	return b == 0 ? a : gcd(b, a%b);
}
ll lcm(ll a, ll b)
{
	return a / gcd(a, b)*b;
}
ll fast_pow(ll a, ll k)//快速幂
{
	ll ans = 1;
	a = a%mod;
	while (k != 0)
	{
		if (k & 1) ans = (ans*a) % mod;
			k >>= 1;
		a = (a*a) % mod;
	}
	return ans;
}
ll C(ll n, ll m)//组合数的计算
{
	ll ans = 1;
	for (ll i = 1;i <= m;i++)
		ans = (ans*(n - m + i) / i) % mod;
	return ans%mod;
}

bool is_prime(ll x)//素数判断
{
	if (x == 2 || x == 3) return true;
	if (x % 6 != 1 && x % 6 != 5) return false;
	ll temp = sqrt(1.0*x);
	for (ll i = 5;i <= temp;i += 6)
		if (x%i == 0 || x % (i + 2) == 0) return false;
	return true;
}
int prime[maxm], pnum = 0;//素数表，pnum是索引
bool p[maxm] = { 0 };//如果被筛掉，就为true
void Find_Prime()//更快的筛选法，遇到一个素数，就把它的倍数全部筛掉
{
	for (int i = 2;i < maxm;i++)
	{
		if (p[i] == false)//不用一个数一个数的判断素数了
		{
			prime[pnum++] = i;
			for (int j = i + i;j < maxm;j += i)//筛掉素数的倍数
				p[j] = true;
		}
	}
}

void Exgcd(ll a, ll b, ll &x, ll &y) {
if (!b) x = 1, y = 0;
else Exgcd(b, a % b, y, x), y -= a / b * x;
}//x是a在mod b下的逆元
ll CRT(int a[],int m[],int n)
{
ll M=1,ans=0,t,x,y;
for(int i=0; i<n; i++)
{
M*=m[i];///M为除数乘积
}
for(int i=0; i<n; i++)
{
t=M/m[i];///除了mi以外的n-1个整数乘积
Exgcd(t,m[i],x,y);///求逆元，由扩展欧几里得转换成t*ti+m[i]*y=1来求ti
ans=(ans+a[i]*x*t)%M;
}
return (ans+M)%M;
}*/

ll a[maxn][maxn], v[maxn];
ll n, m, k;
ll maxnum;
bool vis[maxn];
bool cmp(int x, int y)
{
	return a[x][y] > a[y][x];
}
void dfs(int index, vector<int> &temp)
{
	if (temp.size() == m)
	{
		ll ans = 0;
		vector<int> t;
		for (int i = 0;i < temp.size();i++)
			ans += v[temp[i]];
		t = temp;
		sort(t.begin(), t.end(), cmp);
		for (int i = 1;i < temp.size();i++)
				ans += a[t[i-1]][t[i]];
		if (ans > maxnum) maxnum = ans;
	}
	for (int i = index;i <= n;i++)
	{
		if (!vis[i])
		{
			vis[i] = true;
			temp.push_back(i);
			dfs(i + 1, temp);
			vis[i] = false;
			temp.pop_back();
		}
	}
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cin >> n >> m >> k;
	for (int i = 1;i <= n;i++)
		cin >> v[i];
	for (int i = 0;i < k;i++)
	{
		int x, y, z;
		cin >> x >> y >> z;
		a[x][y] = z;
	}
	vector<int> t;
	dfs(1, t);
	cout << maxnum;
	return ~~(0 - 0);
}


#include<iostream>
#include<stack>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<ctime>
#include<math.h>
#include<functional>
#include<cstring>
#include<iomanip>
#include<set>
#include<utility>
#include<limits.h>
#include<stdio.h>
#define lowbit(x) (x)&(-x)

typedef long long ll;
//状压dp题，本来是想回溯找到所有大小为m的集合，但是找到后不知道如何才能让羁绊凑得最大
using namespace std;
const int maxn = 10 + 10;
const int maxm = 2e5 + 10;
const ll mod = 1e9+7;
const int inf = 0x3ffffff;
const double eps = 1e-5;
/*ll gcd(ll a, ll b)//最大公约数
{
	return b == 0 ? a : gcd(b, a%b);
}
ll lcm(ll a, ll b)
{
	return a / gcd(a, b)*b;
}
ll fast_pow(ll a, ll k)//快速幂
{
	ll ans = 1;
	a = a%mod;
	while (k != 0)
	{
		if (k & 1) ans = (ans*a) % mod;
			k >>= 1;
		a = (a*a) % mod;
	}
	return ans;
}
ll C(ll n, ll m)//组合数的计算
{
	ll ans = 1;
	for (ll i = 1;i <= m;i++)
		ans = (ans*(n - m + i) / i) % mod;
	return ans%mod;
}

bool is_prime(ll x)//素数判断
{
	if (x == 2 || x == 3) return true;
	if (x % 6 != 1 && x % 6 != 5) return false;
	ll temp = sqrt(1.0*x);
	for (ll i = 5;i <= temp;i += 6)
		if (x%i == 0 || x % (i + 2) == 0) return false;
	return true;
}
int prime[maxm], pnum = 0;//素数表，pnum是索引
bool p[maxm] = { 0 };//如果被筛掉，就为true
void Find_Prime()//更快的筛选法，遇到一个素数，就把它的倍数全部筛掉
{
	for (int i = 2;i < maxm;i++)
	{
		if (p[i] == false)//不用一个数一个数的判断素数了
		{
			prime[pnum++] = i;
			for (int j = i + i;j < maxm;j += i)//筛掉素数的倍数
				p[j] = true;
		}
	}
}

void Exgcd(ll a, ll b, ll &x, ll &y) {
if (!b) x = 1, y = 0;
else Exgcd(b, a % b, y, x), y -= a / b * x;
}//x是a在mod b下的逆元
ll CRT(int a[],int m[],int n)
{
ll M=1,ans=0,t,x,y;
for(int i=0; i<n; i++)
{
M*=m[i];///M为除数乘积
}
for(int i=0; i<n; i++)
{
t=M/m[i];///除了mi以外的n-1个整数乘积
Exgcd(t,m[i],x,y);///求逆元，由扩展欧几里得转换成t*ti+m[i]*y=1来求ti
ans=(ans+a[i]*x*t)%M;
}
return (ans+M)%M;
}*/

ll n, m, k, ans;
ll a[20], ad[20][20], f[(1 << 18) + 5][20];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cin >> n >> m >> k;
	for (int i = 0;i < n;i++)
		cin >> a[i];
	for (int i = 0;i < k;i++)
	{
		int x, y, z;
		cin >> x >> y >> z;
		ad[x - 1][y - 1] = z;
	}
	for (int i = 0;i < n;i++)
		f[1 << i][i] = a[i];//先吃一个，满意度为a[i]
	for (int now = 0;now < (1 << n);++now)//枚举状态
	{
		int cnt = 0;//计算已经吃了几道菜
		for (int i = 0;i < n;i++)
		{
			if (now&(1 << i))//枚举吃的最后一道菜
			{
				++cnt;
				for (int j = 0;j < n;j++)//枚举接下来吃的那道菜
					if (!(now&(1 << j)))
						f[now | (1 << j)][j] = max(f[now | (1 << j)][j], f[now][i] + a[j] + ad[i][j]);
				if (cnt == m)
					for (int i = 0;i < n;i++)
						if (now&(1 << i)) ans = max(ans, f[now][i]);
			}
		}
	}
	cout << ans;
	return ~~(0 - 0);
}


#include<iostream>
#include<stack>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<ctime>
#include<math.h>
#include<functional>
#include<cstring>
#include<iomanip>
#include<set>
#include<utility>
#include<limits.h>
#include<stdio.h>
#define lowbit(x) (x)&(-x)

typedef long long ll;
//
using namespace std;
const int maxn = 9 + 10;
const int maxm = 2e5 + 10;
const ll mod = 1e9+7;
const int inf = 0x3ffffff;
const double eps = 1e-5;
/*ll gcd(ll a, ll b)//最大公约数
{
	return b == 0 ? a : gcd(b, a%b);
}
ll lcm(ll a, ll b)
{
	return a / gcd(a, b)*b;
}
ll fast_pow(ll a, ll k)//快速幂
{
	ll ans = 1;
	a = a%mod;
	while (k != 0)
	{
		if (k & 1) ans = (ans*a) % mod;
			k >>= 1;
		a = (a*a) % mod;
	}
	return ans;
}
ll C(ll n, ll m)//组合数的计算
{
	ll ans = 1;
	for (ll i = 1;i <= m;i++)
		ans = (ans*(n - m + i) / i) % mod;
	return ans%mod;
}

bool is_prime(ll x)//素数判断
{
	if (x == 2 || x == 3) return true;
	if (x % 6 != 1 && x % 6 != 5) return false;
	ll temp = sqrt(1.0*x);
	for (ll i = 5;i <= temp;i += 6)
		if (x%i == 0 || x % (i + 2) == 0) return false;
	return true;
}
int prime[maxm], pnum = 0;//素数表，pnum是索引
bool p[maxm] = { 0 };//如果被筛掉，就为true
void Find_Prime()//更快的筛选法，遇到一个素数，就把它的倍数全部筛掉
{
	for (int i = 2;i < maxm;i++)
	{
		if (p[i] == false)//不用一个数一个数的判断素数了
		{
			prime[pnum++] = i;
			for (int j = i + i;j < maxm;j += i)//筛掉素数的倍数
				p[j] = true;
		}
	}
}

void Exgcd(ll a, ll b, ll &x, ll &y) {
if (!b) x = 1, y = 0;
else Exgcd(b, a % b, y, x), y -= a / b * x;
}//x是a在mod b下的逆元
ll CRT(int a[],int m[],int n)
{
ll M=1,ans=0,t,x,y;
for(int i=0; i<n; i++)
{
M*=m[i];///M为除数乘积
}
for(int i=0; i<n; i++)
{
t=M/m[i];///除了mi以外的n-1个整数乘积
Exgcd(t,m[i],x,y);///求逆元，由扩展欧几里得转换成t*ti+m[i]*y=1来求ti
ans=(ans+a[i]*x*t)%M;
}
return (ans+M)%M;
}*/

ll a[maxn][maxn], v[maxn];
ll n, m, k;
ll maxnum;
bool cmp(int x, int y)
{
	return a[x][y] > a[y][x];
}
void dfs(int index, vector<int> &temp)
{
	if (temp.size() == m)
	{
		ll ans = 0;
		for (int i = 0;i < temp.size();i++)
			ans += v[temp[i]];
		sort(temp.begin(), temp.end(), cmp);
		for (int i = 1;i < temp.size();i++)
			ans += a[temp[i - 1]][temp[i]];
		if (ans > maxnum) maxnum = ans;
	}
	if (temp.size() > m || index == n + 1) return;
	temp.push_back(index);
	dfs(index + 1, temp);
	temp.pop_back();
	dfs(index + 1, temp);

}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cin >> n >> m >> k;
	for (int i = 1;i <= n;i++)
		cin >> v[i];
	for (int i = 0;i < k;i++)
	{
		int x, y, z;
		cin >> x >> y >> z;
		a[x][y] = z;
	}
	vector<int> t;
	dfs(1, t);
	cout << maxnum;
	return ~~(0 - 0);
}


#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
typedef long long ll;
const int M = 3e5 + 10;
int a[20] , ve[20][20] , kn[20];
ll dp[20][M];

int main() {
    int n , m , k , u , v , w;
    scanf("%d%d%d" , &n , &m , &k);
    memset(ve , 0 , sizeof(ve));
    for(int i = 0 ; i < n ; i++) {
        scanf("%d" , &a[i]);
    }
    for(int i = 0 ; i < k ; i++) {
        scanf("%d%d%d" , &u , &v , &w);
        ve[u - 1][v - 1] = w;
    }
    memset(dp , 0 , sizeof(dp));
    for(int i = 0 ; i < n ; i++) {
        dp[0][(1 << i)] = (ll)a[i];
    }
    for(int i = 1 ; i < m ; i++) {
        for(int k = 0 ; k < n ; k++) {
            for(int j = 0 ; j < (1 << n) ; j++) {
                memset(kn , 0 , sizeof(kn));
                int pos = (1 << k);
                int num = (j ^ pos);
                if(!(pos & j) && dp[i - 1][j]) {
                    ll sum = 0;
                    int temp = 0;
                    int gg = j;
                    while(gg) {
                        kn[temp++] = gg % 2;
                        gg /= 2;
                    }
                    for(int l = 0 ; l < n ; l++) {
                        if(kn[l] != 1) {
                            kn[l] = 0;
                        }
                    }
                    for(int l = k + 1 ; l < n ; l++) {
                        if(kn[l] == 1 && ve[l][k]) {
                            sum = (ll)ve[l][k];
                            break;
                        }
                    }
                    for(int l = k - 1 ; l >= 0 ; l--) {
                        if(kn[l] == 1 && ve[l][k]) {
                            sum = max(sum , (ll)ve[l][k]);
                            break;
                        }
                    }
                    sum += a[k];
                    //cout << j << ' ' << k << ' ' << num << ' ' << sum << endl;
                    dp[i][num] = max(dp[i][num] , dp[i - 1][j] + sum);
                }
            }
        }
    }
    ll MAX = 0;
    for(int i = 0 ; i < (1 << n) ; i++) {
        MAX = max(MAX , dp[m - 1][i]);
    }
    printf("%I64d\n" , MAX);
    return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
typedef long long ll;
const int M = (1 << 18);
int a[20] , ve[20][20];
ll dp[19][M] , nb[19][M];

int main() {
    int n , m , k , u , v , w;
    scanf("%d%d%d" , &n , &m , &k);
    memset(ve , 0 , sizeof(ve));
    for(int i = 0 ; i < n ; i++) {
        scanf("%d" , &a[i]);
    }
    for(int i = 0 ; i < k ; i++) {
        scanf("%d%d%d" , &u , &v , &w);
        ve[u - 1][v - 1] = w;
    }
    memset(dp , 0 , sizeof(dp));
    for(int i = 0 ; i < n ; i++) {
        dp[0][(1 << i)] = (ll)a[i];
        nb[0][(1 << i)] = i;
    }
    for(int i = 1 ; i < m ; i++) {
        for(int k = 0 ; k < n ; k++) {
            for(int j = 0 ; j < (1 << n) ; j++) {
                int pos = (1 << k);
                int num = (j ^ pos);
                for(int mm = 0 ; mm < n ; mm++) {
                    if(!(pos & j) && dp[i - 1][j] && nb[i - 1][j] == mm) {
                        ll sum = a[k];
                        sum += ve[k][mm];
                        if(dp[i][num] < dp[i - 1][j] + sum) {
                            nb[i][num] = k;
                            dp[i][num] = dp[i - 1][j] + sum;
                        }
                    }
                }
            }
        }
    }
    ll MAX = 0;
    for(int i = 0 ; i < (1 << n) ; i++) {
        MAX = max(MAX , dp[m - 1][i]);
    }
    printf("%I64d\n" , MAX);
    //cout << MAX << endl;
    return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
typedef long long ll;
const int M = (1 << 18);
int a[20] , ve[20][20];
ll dp[M][19] , nb[19][M];

int main() {
    int n , m , k , u , v , w;
    scanf("%d%d%d" , &n , &m , &k);
    memset(ve , 0 , sizeof(ve));
    for(int i = 0 ; i < n ; i++) {
        scanf("%d" , &a[i]);
    }
    for(int i = 0 ; i < k ; i++) {
        scanf("%d%d%d" , &u , &v , &w);
        ve[u - 1][v - 1] = w;
    }
    memset(dp , -1 , sizeof(dp));
    for(int i = 0 ; i < n ; i++) {
        dp[(1 << i)][i] = (ll)a[i];
    }
    ll MAX = 0;
    for(int i = 0 ; i < (1 << n) ; i++) {
        int count = 0;
        int gg = i;
        while(gg) {
            count += gg % 2;
            gg /= 2;
        }
        for(int j = 0 ; j < n ; j++) {
            if(dp[i][j] != -1) {
                if(count == m) {
                    MAX = max(MAX , dp[i][j]);
                }
                for(int k = 0 ; k < n ; k++) {
                    if(!(i & (1 << k))) {
                        ll sum = 0;
                        sum += (ll)ve[j][k];
                        sum += (ll)a[k];
                        dp[i | (1 << k)][k] = max(dp[i | (1 << k)][k] , dp[i][j] + sum);
                    }
                }
            }
        }
    }
    printf("%I64d\n" , MAX);
    //cout << MAX << endl;
    return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
typedef long long ll;
const int M = 3e5 + 10;
int a[20] , ve[20][20] , kn[20];
ll dp[20][M];

int main() {
    int n , m , k , u , v , w;
    scanf("%d%d%d" , &n , &m , &k);
    memset(ve , 0 , sizeof(ve));
    for(int i = 0 ; i < n ; i++) {
        scanf("%d" , &a[i]);
    }
    for(int i = 0 ; i < k ; i++) {
        scanf("%d%d%d" , &u , &v , &w);
        ve[u - 1][v - 1] = w;
    }
    memset(dp , 0 , sizeof(dp));
    for(int i = 0 ; i < n ; i++) {
        dp[0][(1 << i)] = (ll)a[i];
    }
    for(int i = 1 ; i < m ; i++) {
        for(int k = 0 ; k < n ; k++) {
            for(int j = 0 ; j < (1 << n) ; j++) {
                memset(kn , 0 , sizeof(kn));
                int pos = (1 << k);
                int num = (j ^ pos);
                if(!(pos & j) && dp[i - 1][j]) {
                    ll sum = 0;
                    int temp = 0;
                    int gg = j;
                    while(gg) {
                        kn[temp++] = gg % 2;
                        gg /= 2;
                    }
                    for(int l = temp ; l < n ; l++) {
                        kn[l] = 0;
                    }
                    for(int l = k ; l < n ; l++) {
                        if(kn[l] == 1 && ve[l][k]) {
                            sum = (ll)ve[l][k];
                            break;
                        }
                    }
                    for(int l = k ; l >= 0 ; l--) {
                        if(kn[l] == 1 && !ve[l][k]) {
                            sum = max(sum , (ll)ve[l][k]);
                            break;
                        }
                    }
                    sum += a[k];
                    //cout << j << ' ' << k << ' ' << num << ' ' << sum << endl;
                    dp[i][num] = max(dp[i][num] , dp[i - 1][j] + sum);
                }
            }
        }
    }
    long long MAX = 0;
    for(int i = 0 ; i < (1 << n) ; i++) {
        MAX = max(MAX , dp[m - 1][i]);
    }
    cout << MAX << endl;
    return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
typedef long long ll;
const int M = (1 << 18);
int a[20] , ve[20][20];
ll dp[M][19] , nb[19][M];

int main() {
    int n , m , k , u , v , w;
    scanf("%d%d%d" , &n , &m , &k);
    memset(ve , 0 , sizeof(ve));
    for(int i = 0 ; i < n ; i++) {
        scanf("%d" , &a[i]);
    }
    for(int i = 0 ; i < k ; i++) {
        scanf("%d%d%d" , &u , &v , &w);
        ve[u - 1][v - 1] = w;
    }
    memset(dp , -1 , sizeof(dp));
    for(int i = 0 ; i < n ; i++) {
        dp[(1 << i)][i] = (ll)a[i];
    }
    ll MAX = 0;
    for(int i = 0 ; i < (1 << n) ; i++) {
        int count = 0;
        int gg = i;
        while(gg) {
            count += gg % 2;
            gg /= 2;
        }
        for(int j = 0 ; j < n ; j++) {
            if(dp[i][j] != -1) {
                if(count == m) {
                    MAX = max(MAX , dp[i][j]);
                }
                for(int k = 0 ; k < n ; k++) {
                    if(!(i & (1 << k))) {
                        ll sum = 0;
                        sum += (ll)ve[j][k];
                        sum += (ll)a[k];
                        dp[i | (1 << k)][k] = max(dp[i | (1 << k)][k] , dp[i][j] + sum);
                    }
                }
            }
        }
    }
    //printf("%I64d\n" , MAX);
    cout << MAX << endl;
    return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
typedef long long ll;
const int M = (1 << 18);
int a[20] , ve[20][20];
ll dp[19][M] , nb[19][M];

int main() {
    int n , m , k , u , v , w;
    scanf("%d%d%d" , &n , &m , &k);
    memset(ve , 0 , sizeof(ve));
    for(int i = 0 ; i < n ; i++) {
        scanf("%d" , &a[i]);
    }
    for(int i = 0 ; i < k ; i++) {
        scanf("%d%d%d" , &u , &v , &w);
        ve[u - 1][v - 1] = w;
    }
    memset(dp , 0 , sizeof(dp));
    for(int i = 0 ; i < n ; i++) {
        dp[0][(1 << i)] = (ll)a[i];
        nb[0][(1 << i)] = i;
    }
    for(int i = 1 ; i < m ; i++) {
        for(int k = 0 ; k < n ; k++) {
            for(int j = 0 ; j < (1 << n) ; j++) {
                int pos = (1 << k);
                int num = (j ^ pos);
                for(int mm = 0 ; mm < n ; mm++) {
                    if(!(pos & j) && dp[i - 1][j] && nb[i - 1][j] == mm) {
                        ll sum = (ll)a[k];
                        sum += (ll)ve[k][mm];
                        if(dp[i][num] < dp[i - 1][j] + sum) {
                            nb[i][num] = k;
                            dp[i][num] = dp[i - 1][j] + sum;
                        }
                    }
                }
            }
        }
    }
    ll MAX = 0;
    for(int i = 0 ; i < (1 << n) ; i++) {
        MAX = max(MAX , dp[m - 1][i]);
    }
    printf("%I64d\n" , MAX);
    //cout << MAX << endl;
    return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
typedef long long ll;
const int M = (1 << 18);
int a[20] , ve[20][20];
ll dp[M][19];

int main() {
    int n , m , k , u , v , w;
    scanf("%d%d%d" , &n , &m , &k);
    memset(ve , 0 , sizeof(ve));
    for(int i = 0 ; i < n ; i++) {
        scanf("%d" , &a[i]);
    }
    for(int i = 0 ; i < k ; i++) {
        scanf("%d%d%d" , &u , &v , &w);
        ve[u - 1][v - 1] = w;
    }
    memset(dp , -1 , sizeof(dp));
    for(int i = 0 ; i < n ; i++) {
        dp[(1 << i)][i] = (ll)a[i];
    }
    ll MAX = 0;
    for(int i = 0 ; i < (1 << n) ; i++) {
        int count = 0;
        int gg = i;
        while(gg) {
            count += gg % 2;
            gg /= 2;
        }
        for(int j = 0 ; j < n ; j++) {
            if(dp[i][j] != -1) {
                if(count == m) {
                    MAX = max(MAX , dp[i][j]);
                }
                for(int k = 0 ; k < n ; k++) {
                    if(!(i & (1 << k))) {
                        ll sum = 0;
                        sum += (ll)ve[j][k];
                        sum += (ll)a[k];
                        dp[i | (1 << k)][k] = max(dp[i | (1 << k)][k] , dp[i][j] + sum);
                    }
                }
            }
        }
    }
    printf("%I64d\n" , MAX);
    //cout << MAX << endl;
    return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
typedef long long ll;
const int M = (1 << 18);
int a[20] , ve[20][20] , kn[20];
ll dp[19][M][19];

int main() {
    int n , m , k , u , v , w;
    scanf("%d%d%d" , &n , &m , &k);
    memset(ve , 0 , sizeof(ve));
    for(int i = 0 ; i < n ; i++) {
        scanf("%d" , &a[i]);
    }
    for(int i = 0 ; i < k ; i++) {
        scanf("%d%d%d" , &u , &v , &w);
        ve[u - 1][v - 1] = w;
    }
    memset(dp , 0 , sizeof(dp));
    for(int i = 0 ; i < n ; i++) {
        dp[0][(1 << i)][i] = (ll)a[i];
    }
    for(int i = 1 ; i < m ; i++) {
        for(int k = 0 ; k < n ; k++) {
            for(int j = 0 ; j < (1 << n) ; j++) {
                memset(kn , 0 , sizeof(kn));
                int pos = (1 << k);
                int num = (j ^ pos);
                for(int mm = 0 ; mm < n ; mm++) {
                    if(!(pos & j) && dp[i - 1][j][mm]) {
                        ll sum = a[k];
                        sum += ve[k][mm];
                        //cout << j << ' ' << k << ' ' << num << ' ' << sum << endl;
                        dp[i][num][k] = max(dp[i][num][k] , dp[i - 1][j][mm] + sum);
                    }
                }
            }
        }
    }
    ll MAX = 0;
    for(int i = 0 ; i < (1 << n) ; i++) {
        for(int j = 0 ; j < n ; j++) {
            MAX = max(MAX , dp[m - 1][i][j]);
        }
    }
    printf("%I64d\n" , MAX);
    return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
typedef long long ll;
const int M = 3e5 + 10;
int a[20] , ve[20][20] , kn[20];
ll dp[20][M][20];

int main() {
    int n , m , k , u , v , w;
    scanf("%d%d%d" , &n , &m , &k);
    memset(ve , 0 , sizeof(ve));
    for(int i = 0 ; i < n ; i++) {
        scanf("%d" , &a[i]);
    }
    for(int i = 0 ; i < k ; i++) {
        scanf("%d%d%d" , &u , &v , &w);
        ve[u - 1][v - 1] = w;
    }
    memset(dp , 0 , sizeof(dp));
    for(int i = 0 ; i < n ; i++) {
        dp[0][(1 << i)][i] = (ll)a[i];
    }
    for(int i = 1 ; i < m ; i++) {
        for(int k = 0 ; k < n ; k++) {
            for(int j = 0 ; j < (1 << n) ; j++) {
                memset(kn , 0 , sizeof(kn));
                int pos = (1 << k);
                int num = (j ^ pos);
                for(int mm = 0 ; mm < n ; mm++) {
                    if(!(pos & j) && dp[i - 1][j][mm]) {
                        ll sum = a[k];
                        sum += ve[k][mm];
                        //cout << j << ' ' << k << ' ' << num << ' ' << sum << endl;
                        dp[i][num][k] = max(dp[i][num][k] , dp[i - 1][j][mm] + sum);
                    }
                }
            }
        }
    }
    ll MAX = 0;
    for(int i = 0 ; i < (1 << n) ; i++) {
        for(int j = 0 ; j < n ; j++) {
            MAX = max(MAX , dp[m - 1][i][j]);
        }
    }
    printf("%I64d\n" , MAX);
    return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
typedef long long ll;
const int M = (1 << 18);
int a[20] , ve[20][20];
ll dp[19][M] , nb[19][M];

int main() {
    int n , m , k , u , v , w;
    scanf("%d%d%d" , &n , &m , &k);
    memset(ve , 0 , sizeof(ve));
    for(int i = 0 ; i < n ; i++) {
        scanf("%d" , &a[i]);
    }
    for(int i = 0 ; i < k ; i++) {
        scanf("%d%d%d" , &u , &v , &w);
        ve[u - 1][v - 1] = w;
    }
    memset(dp , -1 , sizeof(dp));
    memset(nb , -1 , sizeof(nb));
    for(int i = 0 ; i < n ; i++) {
        dp[0][(1 << i)] = (ll)a[i];
        nb[0][(1 << i)] = i;
    }
    for(int i = 1 ; i < m ; i++) {
        for(int k = 0 ; k < n ; k++) {
            for(int j = 0 ; j < (1 << n) ; j++) {
                int pos = (1 << k);
                int num = (j ^ pos);
                for(int mm = 0 ; mm < n ; mm++) {
                    if(!(pos & j) && dp[i - 1][j] != -1 && nb[i - 1][j] == mm) {
                        ll sum = (ll)a[k];
                        sum += (ll)ve[k][mm];
                        if(dp[i][num] < dp[i - 1][j] + sum) {
                            nb[i][num] = k;
                            dp[i][num] = dp[i - 1][j] + sum;
                        }
                    }
                }
            }
        }
    }
    ll MAX = 0;
    for(int i = 0 ; i < (1 << n) ; i++) {
        MAX = max(MAX , dp[m - 1][i]);
    }
    printf("%I64d\n" , MAX);
    //cout << MAX << endl;
    return 0;
}


#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
typedef long long ll;
const int M = 3e5 + 10;
int a[20] , ve[20][20];
ll dp[20][M];

int main() {
    int n , m , k , u , v , w;
    scanf("%d%d%d" , &n , &m , &k);
    memset(ve , 0 , sizeof(ve));
    for(int i = 0 ; i < n ; i++) {
        scanf("%d" , &a[i]);
    }
    for(int i = 0 ; i < k ; i++) {
        scanf("%d%d%d" , &u , &v , &w);
        ve[u - 1][v - 1] = w;
    }
    memset(dp , 0 , sizeof(dp));
    for(int i = 0 ; i < n ; i++) {
        dp[0][(1 << i)] = (ll)a[i];
    }
    for(int i = 1 ; i < m ; i++) {
        for(int k = 0 ; k < n ; k++) {
            for(int j = 0 ; j < (1 << n) ; j++) {
                int pos = (1 << k);
                int num = (j ^ pos);
                if(!(pos & j) && dp[i - 1][j]) {
                    ll sum = a[k];
                    int temp = 0;
                    int gg = num;
                    while(gg) {
                        if(gg % 2 == 1) {
                            sum += (long long)ve[temp][k];
                        }
                        gg /= 2;
                        temp++;
                    }
                    //cout << j << ' ' << pos << ' ' << num << ' ' << sum << endl;
                    dp[i][num] = max(dp[i][num] , dp[i - 1][j] + sum);
                }
            }
        }
    }
    long long MAX = 0;
    for(int i = 0 ; i < (1 << n) ; i++) {
        MAX = max(MAX , dp[m - 1][i]);
    }
    cout << MAX << endl;
    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using _TYPE = int;
typedef tree< _TYPE, null_type, less< _TYPE >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

int n, m, k;
int offer[20][20];
int satisf[20];
ll dp[20][1 << 20];

ll solve(int index, int mask) {
    if(__builtin_popcount(mask) == m)
        return 0;
    if(index == n)
        return (ll)-1e17;
    ll &rt = dp[index][mask];
    if(rt != -1)
        return rt;
    rt = (ll)-1e17;
    for(int i = 0; i < n; i++) {
        //Check if this item is already taken
        if(mask & (1 << i))
            continue;
        //If I'm not take, try taking me and then look for others
        if(!(mask & (1 << index)))
            rt = max(rt, solve(i, mask | (1 << i)) + (ll) satisf[index]);
        else
            rt = max(rt, solve(i, mask | (1 << i)) + (ll) satisf[index] + offer[index][i]);
    }
    return rt;
}

int main() {
    IO;
    cin >> n >> m >> k;
    for(int i = 0; i < n; i++)
        cin >> satisf[i];
    for(int i = 0; i < k; i++) {
        int u, v, c;
        cin >> u >> v >> c;
        offer[--u][--v] = c;
    }
    memset(dp, -1, sizeof dp);
    cout << solve(0, 0);
    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using _TYPE = int;
typedef tree< _TYPE, null_type, less< _TYPE >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

int n, m, k;
int satisfaction[20];
vector<pair<int, int>> offers[20];
int dp[20][1 << 18];

int solve(int index, int mask) {
    if(index == n) {
        int cntOn = 0;
        for(int i = 0; i <= 21; i++) {
            if(mask & (1 << i))
                cntOn++;
        }
        if(cntOn == m)
            return 0;
        return (int) -1e9;
    }
    int &rt = dp[index][mask];
    if(rt != -1)
        return rt;
    rt = (int) -1e9;
    // try not taking me and go to next one
    rt = max(rt, solve(index + 1, mask));
    // try taking me and if I have offer dont use me as an offer, and Im not taken
    if(!(mask & (1 << index)))
        rt = max(rt, solve(index + 1, mask | (1 << index)) + satisfaction[index]);
    //If I have an offer with another one, try take me with the offers I have and maximize
    if((int) offers[index].size()) {
        //loop through all other dishes I have offer with
        for(auto p : offers[index]) {
            int toTake = p.first, cost = p.second;
            //if the dish I'm connected with is still NOT taken
            if(!(mask & (1 << toTake))) {
                //next two lines: mark me as taken, and mark the dish I'm connected to as taken so as to take the offer
                int x = mask | (1 << toTake);
                x = x | (1 << index);
                rt = max(rt, solve(index + 1, x) + cost + satisfaction[index] + satisfaction[toTake]);
            }
        }
    }
    return rt;
}

int main() {
    IO;
    cin >> n >> m >> k;
    for(int i = 0; i < n; i++)
        cin >> satisfaction[i];
    for(int i = 0; i < k; i++) {
        int u, v, c;
        cin >> u >> v >> c;
        offers[--u].push_back({--v, c});
    }
    memset(dp, -1, sizeof dp);
    cout << solve(0, 0);
    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using _TYPE = int;
typedef tree< _TYPE, null_type, less< _TYPE >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const int MAX = (int) 18;
ll dp[MAX + 1][(1 << MAX)];
int cost[MAX][MAX];
int inp[MAX];
int n, m, k;

ll solve(int index, int mask) {
    if(__builtin_popcount(mask) == m)
        return 0;
    if(index == n)
        return (ll) -1e17;
    ll &rt = dp[index][mask];
    if(rt != -1)
        return rt;
    rt =  (ll) -1e17;
    for(int i = 0; i < n; i++) {
        //If the current item at index i has been already taken
        if(mask & (1 << i))
            continue;
        rt = max(rt, solve(i, mask | (1 << i)) + inp[i] + cost[index][i]);
    }
    return rt;
}

int main() {
    IO;
    cin >> n >> m >> k;
    for(int i = 0; i < n; i++)
        cin >> inp[i];
    for(int i = 0; i < k; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        cost[--a][--b] = c;
    }
    memset(dp, -1, sizeof(dp));
    cout << solve(0, 0);
    return 0;
}