#include <bits/stdc++.h>
using namespace std;
vector<int> adj[100000 + 5];
int C[100000 + 5], grupo[100000 + 5], pd[100000 + 5];
pair<int, int> A[100000 + 5];
bool vis[100000 + 5];
int FIND(int x) {
  if (x != pd[x]) {
    pd[x] = FIND(pd[x]);
  }
  return pd[x];
}
void UNION(int x, int y) {
  int px = FIND(x), py = FIND(y);
  pd[px] = py;
}
int main() {
  int n, m, x, y;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &x);
    A[i] = make_pair(x, i);
    pd[i] = i, grupo[i] = 1;
  }
  sort(A, A + n);
  reverse(A, A + n);
  for (int i = 0; i < m; ++i) {
    scanf("%d%d", &x, &y);
    x--, y--;
    adj[x].push_back(y), adj[y].push_back(x);
  }
  long long res = 0LL;
  for (int i = 0; i < n; ++i) {
    int u = A[i].second, val = A[i].first;
    int sz = adj[u].size();
    for (int j = 0; j < sz; ++j) {
      int v = adj[u][j];
      if (vis[v]) {
        if (FIND(u) != FIND(v)) {
          int ct = grupo[FIND(v)];
          int cur = grupo[FIND(u)];
          res += ((long long)ct * (long long)cur * (long long)val);
          grupo[FIND(v)] = 0;
          UNION(u, v);
          grupo[FIND(u)] = ct + cur;
        }
      }
    }
    vis[u] = 1;
  }
  long long ways = (long long)n * (long long)(n - 1);
  double ans = res * 2.0 / ways;
  printf("%.6lf\n", ans);
}
