#include <bits/stdc++.h>
using namespace std;
const char IO_MODE = 0;
inline long long ReadInt() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
inline void WriteInt(long long x) {
  char CH[20];
  if (x < 0) putchar('-');
  x = -x;
  int Num = 0;
  if (!x) {
    putchar('0');
    return;
  }
  while (x > 0) CH[++Num] = x % 10, x /= 10;
  while (Num) putchar(CH[Num--] + 48);
}
inline void out(int x) {
  if (IO_MODE & 1)
    WriteInt(x);
  else
    printf("%i", x);
}
template <typename... Args>
inline void out(int x, Args... args) {
  out(x);
  putc(' ', stdout);
  out(args...);
}
inline void in(int &x) {
  if (IO_MODE & 2)
    x = ReadInt();
  else
    scanf("%i", &x);
}
template <typename... Args>
inline void in(int &x, Args &...args) {
  in(x);
  in(args...);
}
inline void outll(long long x) {
  if (IO_MODE & 1)
    WriteInt(x);
  else
    printf("%I64d", x);
}
template <typename... Args>
inline void outll(long long x, Args... args) {
  outll(x);
  putc(' ', stdout);
  outll(args...);
}
inline void inll(long long &x) {
  if (IO_MODE & 2)
    x = ReadInt();
  else
    scanf("%I64d", &x);
}
template <typename... Args>
inline void inll(long long &x, Args &...args) {
  inll(x);
  inll(args...);
}
int aa, bb, cc, dd, ee, ff, gg, hh, ii, jj, kk, mm, nn, oo, pp, qq, rr, ss, tt,
    uu, vv, ww, xx, yy, zz;
int tc;
int n, m;
int A[100100];
vector<pair<int, pair<int, int> > > edgeList;
struct DSU {
  vector<int> P, Rank, SetSize;
  int NumDS;
  DSU(int n) {
    SetSize.assign(n, 1);
    Rank.assign(n, 0);
    P.assign(n, 0);
    NumDS = n;
    for (int i = 0; i < n; i++) P[i] = i;
  }
  void AddSet() {
    SetSize.push_back(1);
    Rank.push_back(0);
    P.push_back(P.size());
    NumDS++;
  }
  int FindSet(int x) { return P[x] == x ? x : P[x] = FindSet(P[x]); }
  bool isSameSet(int x, int y) { return FindSet(x) == FindSet(y); }
  void UnionSet(int x, int y) {
    if (!isSameSet(x, y)) {
      NumDS--;
      int X = FindSet(x);
      int Y = FindSet(y);
      if (Rank[X] > Rank[Y])
        P[Y] = X, SetSize[X] += SetSize[Y];
      else
        P[X] = Y, SetSize[Y] += SetSize[X], Rank[Y] += Rank[X] == Rank[Y];
    }
  }
  int NumOfDS() { return NumDS; }
  int SizeOfSet(int x) { return SetSize[FindSet(x)]; }
};
int main() {
  in(n, m);
  for (int i = 0; i < n; i++) in(A[i]);
  for (int i = 0; i < m; i++) {
    in(uu, vv);
    uu--;
    vv--;
    edgeList.push_back({min(A[uu], A[vv]), {uu, vv}});
  }
  sort(edgeList.begin(), edgeList.end(),
       greater<pair<int, pair<int, int> > >());
  long long ans = 0;
  DSU dsu(n);
  for (auto e : edgeList) {
    if (dsu.NumOfDS() == 1) break;
    int u = e.second.first;
    int v = e.second.second;
    if (dsu.isSameSet(u, v)) continue;
    ans += (long long)dsu.SizeOfSet(u) * dsu.SizeOfSet(v) * e.first;
    dsu.UnionSet(u, v);
  }
  cout << fixed << setprecision(7) << 2.0 * ans / ((long long)n * (n - 1))
       << endl;
}
