#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
#define ll long long
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, m, k;
    cin >> k >> n >> m;
    vector<int> a(n, 0);
    for(int i = 0; i < k; i++){
        int x;
        cin >> x;
        a[x - 1]++;
    }
    vector<int> b(n);
    for(int i = 0; i < n; i++){
        cin >> b[i];
    }
    mcf_graph<int, ll> g(n + 5);
    int S = n;
    int T = n + 1;
    for(int i = 0; i < n; i++){
        g.add_edge(S, i, a[i], 0);
        g.add_edge(i, T, b[i], 0);
    }
    for(int i = 0; i < m; i++){
        int s, t;
        ll d;
        cin >>s>>t>>d;
        s--; t--;
        g.add_edge(s, t, k, d);
        g.add_edge(t, s, k, d);

    }
    pair<int, ll> f = g.flow(S, T);
    cout << f.second << endl;
    return 0;
}