#include <bits/stdc++.h>
using namespace std;
struct edge {
  int t;
  edge *next;
};
struct obj {
  int v, a, b;
  obj() {}
  obj(int a0, int b0, int v0) { v = v0, a = a0, b = b0; }
};
inline bool cmpObj(obj a, obj b) { return a.v < b.v; }
const int maxn = 1010;
const int maxm = 4010;
obj o[maxm];
edge *ep, *head[maxn];
int n, m, v[maxn], vis[maxn], vo, s;
void addEdge(int u, int v) {
  ep->t = v;
  ep->next = head[u];
  head[u] = ep++;
}
bool reach(int st, int te) {
  queue<int> q;
  q.push(st);
  vis[st] = vo;
  while (!q.empty() && vis[te] != vo) {
    int p = q.front();
    q.pop();
    for (edge *g = head[p]; g; g = g->next)
      if (vis[g->t] != vo) {
        vis[g->t] = vo;
        q.push(g->t);
      }
  }
  return vis[te] == (vo++);
}
int main() {
  memset(vis, -1, sizeof(vis));
  vo = 0;
  ep = new edge[maxm];
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", v + i);
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    o[i << 1] = obj(a, b, v[b]);
    o[(i << 1) + 1] = obj(b, a, v[a]);
  }
  sort(o, o + m * 2, cmpObj);
  s = 0;
  for (int i = 0; i < m * 2; i++)
    if (!reach(o[i].b, o[i].a)) {
      s += o[i].v;
      addEdge(o[i].a, o[i].b);
    }
  printf("%d\n", s);
}
