//Jakub Staroń
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstdio>

#ifdef COMPILING_HOME
#define DEBUG_MODE
#define HAVE_NEW_STANDARD
#endif

#ifdef HAVE_NEW_STANDARD
#include <unordered_map>
#include <unordered_set>
#else
#include <tr1/unordered_map>
#include <tr1/unordered_set>
using namespace std::tr1;
#endif

#define hash_map      unordered_map
#define hash_multimap unordered_multimap
#define hash_set      unordered_set
#define hash_multiset unordered_multiset

using namespace std;

typedef char int8;
typedef unsigned char uint8;
typedef short int int16;
typedef unsigned short int uint16;
typedef int int32;
typedef unsigned int uint32;
typedef long long int64;
typedef unsigned long long uint64;

typedef std::pair<int32,int32> int32_pair;
typedef std::pair<uint32, uint32> uint32_pair;
typedef std::pair<int64,int64> int64_pair;
typedef std::pair<uint64,uint64> uint64_pair;

typedef std::vector<bool> bit_vector;

#ifdef HAVE_NEW_STANDARD
#define let(a,b) auto a = (b)
#else
#define let(a,b) __typeof (b) a = (b)
#endif

#ifdef DEBUG_MODE
#define pause system("pause")
#define clear_screen system("cls")
#define print(x) cerr << #x << " = " << x << endl
#define label_print(label, value) cerr << label << ' ' << value << endl
#define debug(x) x
#define line cerr << "Line " << __LINE__ << endl
#include <cassert>
#else
#define pause
#define clear_screen
#define print(x)
#define label_print(label, value)
#define debug(x)
#define assert(x)
#define line
#endif

#define rep(i,x) for(uint32 i = 0 ; i < (x) ; i++)
#define for_range(i,begin,end) for( let(i, (begin) ) ; i != (end) ; ++i )
#define foreach(i, c) for_range(i, c.begin(), c.end())
#define abs(a) ( (a) < 0 ? -(a) : (a) )
#define all(c) (c).begin(),(c).end()
#define sort_all(x) sort( all(x) )
#define divide(a,b) ( ( (b)%(a) ) == 0 )
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)

#define min(a,b) ( (a) < (b)? (a) : (b) )
#define max(a,b) ( (a) > (b)? (a) : (b) )
#define min3(a,b,c) (  min((a), min((b),(c))) )
#define max3(a,b,c) (  max((a), max((b),(c))) )
#define sig(x) ( (x) == 0 ? 0 : ( (x) < 0 ? -1 : 1 ) )

const double epsilon = 1e-5;

template<class T>
void unique(std::vector<T>& v)
{
	sort_all(v);
	v.resize( std::unique(all(v)) - v.begin() );
}

ostream& newline(ostream& str)
{
	str.put('\n');
	return str;
}

template<typename T1, typename T2>
istream& operator>>(istream& stream, std::pair<T1, T2>& pair)
{
	stream >> pair.first >> pair.second;
	return stream;
}

template<typename T1, typename T2>
ostream& operator<<(ostream& stream, const std::pair<T1, T2>& pair)
{
#ifdef DEBUG_MODE
	stream << "(" << pair.first << ", " << pair.second << ")";
#else
	stream << pair.first << ' ' << pair.second;
#endif
	return stream;
}


typedef pair<uint32, uint32_pair> reakcja_type;

class Application
{
public:
	Application()
	{
	}

	void Run()
	{
		WczytajDane();
		int64 result = 0;
		for(const uint32_pair& ab : kolejnosc)
		{
			uint32 a,b;
			a = ab.first;
			b = ab.second;

			if(S[a].size() > S[b].size())
				swap(S[a], S[b]);

			vector<reakcja_type> reakcje = GenerujReakcje(a,b);

			S[b].insert( all(S[a]) );
			S[a].clear();


			for(const reakcja_type& reakcja : reakcje)
			{
				const uint32_pair& ab = reakcja.second;

				/*
				wywalannie z R
				*/

				auto it1 = S[b].find(ab.first);
				auto it2 = S[b].find(ab.second);

				if(it1 != S[b].end() && it2 != S[b].end())
				{
					uint32 osad = min(it1->second, it2->second);
					result += 2 * osad;

					it1->second -= osad;
					it2->second -= osad;

					if(it1->second == 0)					
						S[b].erase(it1);

					if(it2->second == 0)					
						S[b].erase(it2);	
				}
			}			
		}

		cout << result << newline;
	}

	vector<reakcja_type> GenerujReakcje(uint32 a, uint32 b)
	{
		vector<reakcja_type> reakcje;

		for(auto& p : S[a])
		{
			uint32 third = p.first;/*
			for(const reakcja_type& w : R[third])
			{
				uint32 forth = (w.second.first == third? w.second.second : w.second.first);
				if(S[b].count(forth))
				{
					reakcje.pb(w);
				}
			}*/

			for(int32 i = 0 ; i < int32(R[third].size()) ; i++ )
			{
				const reakcja_type& w = R[third][i];
				uint32 forth = (w.second.first == third? w.second.second : w.second.first);
				if(S[b].count(forth))
				{
					reakcje.pb(w);
					swap(R[third][i], R[third].back());
					R[third].pop_back();
					i--;
				}
			}
		}

		unique(reakcje);
		return reakcje;
	}

	void WczytajDane()
	{
		cin >> N >> M >> K;
		R.resize(N);
		S.resize(N);
		kolejnosc.resize(M);
		rep(i, N)
		{
			uint32 a;
			cin >> a;
			S[i][i] = a;
		}


		rep(i, M)
		{
			cin >> kolejnosc[i];
			kolejnosc[i].first--;
			kolejnosc[i].second--;
		}
		

		rep(i, K)
		{
			uint32 a,b;
			cin >> a >> b;
			a--,b--;
			uint32_pair ab(a,b);

			R[a].pb( mp(i,ab) );
			R[b].pb( mp(i,ab) );
		}
	}

	uint32 N,M,K;

	vector<uint32_pair> kolejnosc;
	vector< vector<reakcja_type> > R;
	vector< map<uint32, uint32> > S;
};


int main()
{
	ios::sync_with_stdio(0);
	Application application;
	application.Run();
	return 0;
}