#include <bits/stdc++.h>
using namespace std;
const long long N = 2000777;
long long a[N];
long long m, n;
long long parent[N];
long long sz[N];
vector<long long> g[N];
map<pair<long long, long long>, long long> mp;
vector<pair<long long, long long> > v;
void make_set(long long v) {
  parent[v] = v;
  sz[v] = 1;
}
long long find_set(long long v) {
  if (v == parent[v]) return v;
  return parent[v] = find_set(parent[v]);
}
long long union_sets(long long a, long long b) {
  a = find_set(a);
  b = find_set(b);
  if (a != b) {
    if (sz[a] < sz[b]) swap(a, b);
    parent[b] = a;
    long long ans = sz[a] * sz[b];
    sz[a] += sz[b];
    return ans;
  }
  return -1;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (long long i = 1; i <= n; i++) {
    parent[i] = i;
    sz[i] = 1;
  }
  for (long long i = 1; i <= n; i++) {
    long long x;
    cin >> x;
    a[i] = x;
    v.push_back({x, i});
  }
  for (long long i = 1; i <= m; i++) {
    long long x, y;
    cin >> x >> y;
    if (a[x] < a[y]) {
      g[x].push_back(y);
    } else if (a[x] > a[y]) {
      g[y].push_back(x);
    } else {
      if (x < y) {
        g[x].push_back(y);
      } else {
        g[y].push_back(x);
      }
    }
  }
  sort(v.begin(), v.end());
  long long ans = 0;
  for (long long i = v.size() - 2; i >= 0; i--) {
    long long id = v[i].second;
    long long val = v[i].first;
    for (long long j = 0; j < g[id].size(); j++) {
      long long to = g[id][j];
      long long k = union_sets(to, id);
      if (k != -1) {
        ans = ans + val * k;
      }
    }
  }
  long double k = n * (n - 1);
  ans *= 2;
  long double otv = ans;
  otv /= k;
  cout.precision(4);
  cout << fixed << otv << "\n";
  return 0;
}
