#include <bits/stdc++.h>
using namespace std;
pair<long long int, long long int> arr[100005];
long long int visited[100005], par[100005], val[100005];
vector<long long int> v[100005];
bool cmp(pair<long long int, long long int> x,
         pair<long long int, long long int> y) {
  return x.second > y.second;
}
long long int getpar(long long int node) {
  if (par[node] == node) return node;
  return par[node] = getpar(par[node]);
}
int main() {
  long long int i, j, k;
  long long int n, m;
  scanf("%lld", &n);
  scanf("%lld", &m);
  for (i = 1; i <= n; i++) {
    arr[i].first = i;
    scanf("%lld", &arr[i].second);
  }
  for (i = 1; i <= m; i++) {
    scanf("%lld", &j);
    scanf("%lld", &k);
    v[j].push_back(k);
    v[k].push_back(j);
  }
  for (i = 1; i <= n; i++) par[i] = i;
  sort(arr + 1, arr + n + 1, cmp);
  long long ans = 0;
  set<long long int> s;
  for (i = 1; i <= n; i++) {
    s.clear();
    long long int x = arr[i].first;
    visited[x] = 1;
    long long int y = v[x].size();
    long long int temp = 0;
    for (j = 0; j < y; j++) {
      if (visited[v[x][j]] == 1) {
        long long int z = getpar(v[x][j]);
        if (s.find(z) == s.end()) {
          temp += val[z];
          s.insert(z);
        }
      }
    }
    s.clear();
    val[x] = temp + 1;
    for (j = 0; j < y; j++) {
      if (visited[v[x][j]] == 1) {
        long long int z = getpar(v[x][j]);
        if (s.find(z) == s.end()) {
          ans += arr[i].second * (temp - val[z]) * val[z];
          s.insert(z);
        }
      }
    }
    for (j = 0; j < y; j++) {
      if (visited[v[x][j]] == 1) {
        long long int z = getpar(v[x][j]);
        par[z] = x;
      }
    }
    ans += 2 * temp * arr[i].second;
  }
  printf("%lf\n", (double)ans / (n * (n - 1)));
  return 0;
}
