#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
void dfs(vector<vector<int>>& adj, vector<bool>& v, int s,
         vector<pair<int, int>>& cur, vector<int> a) {
  for (auto i : adj[s]) {
    if (v[i] == 0) {
      v[i] = 1;
      cur.push_back(make_pair(a[i], i));
      dfs(adj, v, i, cur, a);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m;
  cin >> n >> m;
  vector<vector<int>> adj(n + 1);
  vector<int> a(n + 1, 0);
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  vector<bool> v(n + 1, 0);
  vector<bool> removed(n + 1, 0);
  long long res = 0;
  for (int i = 1; i <= n; i++) {
    if (v[i] == 0) {
      v[i] = 1;
      vector<pair<int, int>> cur;
      cur.push_back(make_pair(a[i], i));
      dfs(adj, v, i, cur, a);
      sort(cur.begin(), cur.end());
      for (int i = cur.size() - 1; i >= 0; i--) {
        if (!removed[cur[i].second]) {
          removed[cur[i].second] = 1;
          for (auto j : adj[cur[i].second]) {
            if (!removed[j]) res += a[j];
          }
        }
      }
    }
  }
  cout << res << "\n";
}
