#include <bits/stdc++.h>
using namespace std;
pair<int, int> a[110000];
int v[110000];
vector<int> g[110000];
bool u[110000];
int f[110000];
int size[110000];
int parent[110000];
int ancestor(int x) {
  if (parent[x] == x) return x;
  return parent[x] = ancestor(parent[x]);
}
int main() {
  cout << fixed << setprecision(6);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    a[i].first = v[i];
    a[i].second = i;
  }
  for (int i = 0; i < n; i++) {
    parent[i] = i;
    size[i] = 1;
  }
  sort(a, a + n);
  reverse(a, a + n);
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    int src = a[i].second;
    int c = 0;
    for (int j = 0; j < g[src].size(); j++) {
      int dest = g[src][j];
      if (u[dest] == true) {
        f[c++] = ancestor(dest);
      }
    }
    sort(f, f + c);
    c = unique(f, f + c) - f;
    int totsize = 0;
    for (int j = 0; j < c; j++) {
      totsize += size[f[j]];
    }
    ans += 2LL * totsize * v[src];
    for (int j = 0; j < c; j++) {
      ans += (long long)(totsize - size[f[j]]) * size[f[j]] * v[src];
      parent[ancestor(f[j])] = src;
    }
    u[src] = true;
    size[src] += totsize;
  }
  cout << (double)ans / n / (n - 1) << endl;
  return 0;
}
