#include <bits/stdc++.h>
using namespace std;
class UF {
  long long int *id, cnt, *sz;

 public:
  UF(long long int N) {
    cnt = N;
    id = new long long int[N + 1];
    sz = new long long int[N + 1];
    for (long long int i = 1; i <= N; i++) {
      id[i] = i;
      sz[i] = 1;
    }
  }
  ~UF() {
    delete[] id;
    delete[] sz;
  }
  long long int find(long long int p) {
    long long int root = p;
    while (root != id[root]) root = id[root];
    while (p != root) {
      long long int newp = id[p];
      id[p] = root;
      p = newp;
    }
    return root;
  }
  void merge(long long int x, long long int y) {
    long long int i = find(x);
    long long int j = find(y);
    if (i == j) return;
    if (sz[i] < sz[j]) {
      id[i] = j;
      sz[j] += sz[i];
    } else {
      id[j] = i;
      sz[i] += sz[j];
    }
    cnt--;
  }
  bool connected(long long int x, long long int y) {
    return find(x) == find(y);
  }
  long long int count() { return cnt; }
};
pair<long long int, long long int> p;
long long int root[1000001];
long long int a[1000001];
vector<long long int> v[1000001];
vector<pair<long long int, long long int> > s;
long long int vis[1000001];
double yy, xx;
long long int n, i, j, k, ans, sum, m, x, y, z, t;
int main() {
  cin >> n >> m;
  UF pad(n);
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    p = make_pair(a[i], i);
    s.push_back(p);
  }
  for (i = 1; i <= m; i++) {
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  sort(s.begin(), s.end());
  for (i = 1; i <= n; i++) root[i] = 1;
  for (i = n - 1; i >= 0; i--) {
    p = s[i];
    x = p.first;
    y = p.second;
    for (j = 0; j < v[y].size(); j++) {
      t = v[y][j];
      if (vis[t] == 0 || pad.find(t) == pad.find(y)) continue;
      ans += x * root[pad.find(t)] * root[pad.find(y)];
      z = root[pad.find(t)] + root[pad.find(y)];
      pad.merge(y, t);
      root[pad.find(y)] = z;
    }
    vis[y] = 1;
  }
  z = n * (n - 1) / 2;
  yy = ans;
  xx = z;
  yy = yy / xx;
  std::cout << std::fixed;
  std::cout << std::setprecision(10);
  std::cout << yy;
}
