#include <bits/stdc++.h>
using namespace std;
long long n, m, a[100010];
int b[100010];
vector<int> e[100010];
int par[100010], sz[100010];
bool cmp(int l, int r) {
  if (a[l] != a[r]) return a[l] > a[r];
  return l > r;
}
int find(int x) {
  if (x == par[x]) return x;
  return par[x] = find(par[x]);
}
void merge(int x, int y) {
  int xx = find(x);
  int yy = find(y);
  if (xx == yy) return;
  par[yy] = xx;
  sz[xx] += sz[yy];
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    b[i] = i;
  }
  sort(b + 1, b + 1 + n, cmp);
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    if (a[x] > a[y] || (a[x] == a[y] && x > y)) swap(x, y);
    e[x].push_back(y);
  }
  for (int i = 1; i <= n; i++) {
    par[i] = i;
    sz[i] = 1;
  }
  long long tot = 0;
  for (int i = 1; i <= n; i++) {
    int id = b[i];
    set<int> s;
    long long sum = 0;
    for (int j = 0; j < e[id].size(); j++) s.insert(find(e[id][j]));
    for (set<int>::iterator it = s.begin(); it != s.end(); it++) {
      sum += sz[*it];
    }
    for (set<int>::iterator it = s.begin(); it != s.end(); it++) {
      tot += (sum - sz[*it]) * sz[*it] * a[id];
    }
    tot += sum * 2 * a[id];
    for (int j = 0; j < e[id].size(); j++) merge(find(id), find(e[id][j]));
  }
  cout << fixed << setprecision(6) << 1.0 * tot / n / (n - 1) << '\n';
}
