Problem: When Kefa came to the restaurant and sat at a table, the waiter immediately brought him the menu. There were n dishes. Kefa knows that he needs exactly m dishes. But at that, he doesn't want to order the same dish twice to taste as many dishes as possible. 

Kefa knows that the i-th dish gives him ai units of satisfaction. But some dishes do not go well together and some dishes go very well together. Kefa set to himself k rules of eating food of the following type — if he eats dish x exactly before dish y (there should be no other dishes between x and y), then his satisfaction level raises by c. 

Of course, our parrot wants to get some maximal possible satisfaction from going to the restaurant. Help him in this hard task!

Input

The first line of the input contains three space-separated numbers, n, m and k (1 ≤ m ≤ n ≤ 18, 0 ≤ k ≤ n * (n - 1)) — the number of dishes on the menu, the number of portions Kefa needs to eat to get full and the number of eating rules.

The second line contains n space-separated numbers ai, (0 ≤ ai ≤ 109) — the satisfaction he gets from the i-th dish.

Next k lines contain the rules. The i-th rule is described by the three numbers xi, yi and ci (1 ≤ xi, yi ≤ n, 0 ≤ ci ≤ 109). That means that if you eat dish xi right before dish yi, then the Kefa's satisfaction increases by ci. It is guaranteed that there are no such pairs of indexes i and j (1 ≤ i < j ≤ k), that xi = xj and yi = yj.

Output

In the single line of the output print the maximum satisfaction that Kefa can get from going to the restaurant.

Examples

Input

2 2 1
1 1
2 1 1


Output

3


Input

4 3 2
1 2 3 4
2 1 5
3 4 2


Output

12

Note

In the first sample it is best to first eat the second dish, then the first one. Then we get one unit of satisfaction for each dish and plus one more for the rule.

In the second test the fitting sequences of choice are 4 2 1 or 2 1 4. In both cases we get satisfaction 7 for dishes and also, if we fulfill rule 1, we get an additional satisfaction 5.

Solution (in JAVA):

Solution:
	import java.io.*;
	import java.util.*;
	import java.math.*;
	
	 
	 public class Main	{
	   static class Pair implements Comparable<Pair>{

		   int a;
		   long b;
		   public Pair(int x,long y){a=x;b=y;}
		   public int compareTo(Pair p){
				 return Long.compare(a, p.a);
		   }
//		@Override
//		public int hashCode() {
//			final int prime = 31;
//			int result = 1;
//			result = prime * result + a;
//			result = prime * result + b;
//		   
//			return result;
//		}
//		@Override
//		public boolean equals(Object obj) {
//			Pair cur = (Pair)obj;
//			if((a==cur.a && b==cur.b))return true;
//			return false;
//		}
	 }
	   static class ArrayUtils {
			public static Integer[] generateOrder(int size) {
				Integer[] order = new Integer[size];
				for (int i = 0; i < size; i++)
					order[i] = i;
				return order;
			}
		 
			public static Integer[] order(int size, Comparator<Integer> comparator) {
				Integer[] order = generateOrder(size);
				Arrays.sort(order, comparator);
				return order;
			}
		 
				}
	static class TrieNode{
		int cnt;
		TrieNode[]child;
		public TrieNode() {
			cnt = 0;
			child = new TrieNode[10];
		}
	}
	  public static long gcd(long a,long b)
	  {
	    if(a<b)
	      return gcd(b,a);
	    if(b==0)
	      return a;
	    return gcd(b,a%b);
	    
	  }
	  static int lcm(int a,int b) {
		  return  a*b / (int)gcd(a,b);
	  }
	  
	  static long mod = 998244353;//(long)(1e9+7); //
	   
	    public static void main(String[] args) throws Exception {
	       new Thread(null, null, "Anshum Gupta", 99999999) {
	            public void run() {
	                try {
	                    solve();
	                } catch(Exception e) {
	                    e.printStackTrace();
	                    System.exit(1);
	                }
	            }
	        }.start();
	    }
	
	static long pow(long x,long y){
	    if(y == 0)return 1;
	    if(y==1)return x;
	    long a = pow(x,y/2);
	    a = (a*a)%mod;
	    if(y%2==0){
	        return a;
	    }
	    return (a*x)%mod;
	}
	
	static long mxx;
	static int mxN = (int)(2e6+5);
	static int mxV = (int)(2e5);
	static long[]fact,inv_fact;
	static long my_inv(long a) {
		return pow(a,mod-2);
	}
	static long bin(int a,int b) {
		if(a < b || a<0 || b<0)return 0;
	    return ((fact[a]*inv_fact[a-b])%mod * inv_fact[b])%mod;
	}
		static ArrayList<ArrayList<Integer>>adj;
		static boolean[]vis;
	static void make_facts() {
	  fact=new long[mxN];
	  inv_fact = new long[mxN];
	  fact[0]=inv_fact[0]=1L;
	  for(int i=1;i<mxN;i++) {
		   fact[i] = (i*fact[i-1])%mod;
		   inv_fact[i] = my_inv(fact[i]);
	  }
	}
     static int n, m, k;
     static long[]a;
     static long[][]dp;
     static ArrayList<ArrayList<Pair>>prev;
     static long[][]cost;
     static long get(int mask) {
    	 long res = 0;
    	 for(int i=0;i<n;i++) {
    		 if( ((1<<i) & mask) > 0){
    			res += a[i];
    		 }
    	 }
    	 return res;
     }
     static long rec(int i, int mask) {
    	 int bc = Integer.bitCount(mask);
    	 if(bc > m) {
    		 return -mxx;
    	 }
    	 if(bc == m)return 0;
    	 if(dp[i][mask] != -1)
    		 return dp[i][mask];
    	 if(bc == m-1) {
    		 return a[i];
    	 }
    	 long res = a[i];
    	 int temp = mask;
    	 mask |= (1<<i);
    	 long mx = 0;
    	 for(int j=0;j<n;j++) {
    		 if((mask & (1<<j)) == 0) { 
    			 mx = Math.max(mx, cost[i][j] + rec(j, mask));
    		 }
    	 }
    	 res += mx;
    	 return dp[i][temp] = res;
     }
	 public static void solve() throws Exception {
	   // solve the problem here
	   MyScanner s = new MyScanner();
	        out = new PrintWriter(new BufferedOutputStream(System.out), true);
	        int tc = 1;//s.nextInt();
	        mxx = (long)(1e18+5);
	//	        make_facts(); 
	//	        int mod = (int)1e9+7;
	        
	        while(tc-->0){
	        	n = s.nextInt();
	        	m = s.nextInt();
	        	k = s.nextInt();
	        	a = new long[n];
	        	for(int i=0;i<n;i++) {
	        		a[i] = s.nextLong();
	        	}
	        	cost = new long[n][n];
	        	for(int i=0;i<k;i++) {
	        		int x = s.nextInt();
	        		int y = s.nextInt();
	        		x--;
	        		y--;
	        		long c = s.nextLong();
	        		cost[x][y] = c;
	        	}
	        	dp = new long[n][(1<<n)];

	        	for(int i=0;i<n;i++)
	        			Arrays.fill(dp[i], -1);
	        	long ans = 0;
	        	for(int i=0;i<n;i++) {
	        		ans = Math.max(ans, rec(i, 0));
	        	}

	        	out.println(ans);
	        }
	        	
	           
	        out.flush();
	}
	 
	     
	 
	 
	 
	    //-----------PrintWriter for faster output---------------------------------
	    public static PrintWriter out;
	 
	    //-----------MyScanner class for faster input----------
	    public static class MyScanner {
	        BufferedReader br;
	        StringTokenizer st;
	 
	        public MyScanner() {
	            br = new BufferedReader(new InputStreamReader(System.in));
	        }
	 
	        String next() {
	            while (st == null || !st.hasMoreElements()) {
	                try {
	                    st = new StringTokenizer(br.readLine());
	                } catch (IOException e) {
	                    e.printStackTrace();
	                }
	            }
	            return st.nextToken();
	        }
	 
	        int nextInt() { return Integer.parseInt(next()); }
	        long nextLong() { return Long.parseLong(next()); }
	        double nextDouble() { return Double.parseDouble(next()); }
	         
	        String nextLine(){
	            String str = "";
	            try {
	                str = br.readLine();
	            } catch (IOException e) {
	                e.printStackTrace();
	            }
	            return str;
	        }
	    }
	    //--------------------------------------------------------
	}