#include <bits/stdc++.h>
using namespace std;
struct unionf {
  vector<int> data;
  unionf(int size) : data(size, -1) {}
  bool unions(int x, int y) {
    x = root(x);
    y = root(y);
    if (x != y) {
      if (data[y] < data[x]) {
        int d = x;
        x = y;
        y = d;
      }
      data[x] += data[y];
      data[y] = x;
    }
    return x != y;
  }
  bool finds(int x, int y) { return root(x) == root(y); }
  int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
  int find(int x) { return -data[x]; }
};
int a[114514];
vector<pair<double, pair<int, int> > > v;
int main() {
  int n, m, x, y;
  double out = 0.0;
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    x--;
    y--;
    v.push_back(make_pair(min(a[x], a[y]), make_pair(x, y)));
  }
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  unionf uni(n + 10);
  for (int i = 0; i < m; i++) {
    x = v[i].second.first;
    y = v[i].second.second;
    if (uni.finds(x, y)) continue;
    out += v[i].first * uni.find(uni.root(x)) * uni.find(uni.root(y));
    uni.unions(x, y);
  }
  printf("%.12f\n", out * 2 / n / (n - 1));
}
