#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;
const double pi = acos(-1.0);
const int N = 20;
ll a[N];
ll c[N][N];
ll dp[1 << 19][19];
int main()
{
int n, m, tot;
scanf("%d%d%d", &n, &tot, &m);
for(int i = 0; i < n; i++)
{
scanf("%lld", &a[i]);
}
while(m--)
{
int x, y;
scanf("%d%d", &x, &y);
scanf("%lld", &c[x - 1][y - 1]);
}
for(int i = 0; i < n; i++)
{
dp[1 << i][i] = a[i];
}
ll ans = 0;
for(int i = 0; i < (1 << (n + 1)) - 1; i++)
{
int cnt = 0;
for(int j = 0; j < n; j++)
{
if(((i >> j) & 1) == 0)
{
continue;
}
cnt++;
for(int k = 0; k < n; k++)
{
if(((i >> k) & 1) == 0)
{
dp[i | (1 << k)][k] = max(dp[i | (1 << k)][k], dp[i][j] + c[j][k] + a[k]);
}
}
}
if(cnt == tot)
{
for(int j = 0; j < n; j++)
{
ans = max(ans, dp[i][j]);
}
}
}
printf("%lld\n", ans);
return 0;
}