#include <bits/stdc++.h>
using namespace std;
template <typename T, typename T1>
ostream &operator<<(ostream &out, pair<T, T1> obj) {
  return out << "(" << obj.first << "," << obj.second << ")";
}
template <typename T, typename T1>
ostream &operator<<(ostream &out, map<T, T1> cont) {
  typename map<T, T1>::const_iterator itr = cont.begin();
  typename map<T, T1>::const_iterator ends = cont.end();
  for (; itr != ends; ++itr) out << *itr << " ";
  out << endl;
}
template <typename T>
ostream &operator<<(ostream &out, set<T> cont) {
  typename set<T>::const_iterator itr = cont.begin();
  typename set<T>::const_iterator ends = cont.end();
  for (; itr != ends; ++itr) out << *itr << " ";
  out << endl;
}
template <typename T,
          template <typename ELEM, typename ALLOC = allocator<ELEM>> class CONT>
ostream &operator<<(ostream &out, CONT<T> cont) {
  typename CONT<T>::const_iterator itr = cont.begin();
  typename CONT<T>::const_iterator ends = cont.end();
  for (; itr != ends; ++itr) out << *itr << " ";
  out << endl;
}
template <typename T, unsigned int N, typename CTy, typename CTr>
typename enable_if<!is_same<T, char>::value, basic_ostream<CTy, CTr> &>::type
operator<<(basic_ostream<CTy, CTr> &out, const T (&arr)[N]) {
  for (auto i = 0 - (0 > N); i != N - (0 > N); i += 1 - 2 * (0 > N))
    out << arr[i] << " ";
  out << endl;
}
template <typename T>
T gcd(T a, T b) {
  T min_v = min(a, b);
  T max_v = max(a, b);
  while (min_v) {
    T temp = max_v % min_v;
    max_v = min_v;
    min_v = temp;
  }
  return max_v;
}
template <typename T>
T lcm(T a, T b) {
  return (a * b) / gcd(a, b);
}
template <typename T>
T fast_exp_pow(T base, T exp, T mod) {
  long long res = 1;
  while (exp) {
    if (exp & 1) {
      res *= base;
      res %= mod;
    }
    exp >>= 1;
    base *= base;
    base %= mod;
  }
  return res;
}
int N, M, X, Y;
int Parent[100010], Rank[100010];
bool availabe[100010];
double counts;
vector<int> graph[100010];
pair<int, int> animals[100010];
int find_parent(int nd) {
  if (Parent[nd] != nd) Parent[nd] = find_parent(Parent[nd]);
  return Parent[nd];
}
void Union(int nd1, int nd2) {
  Parent[nd1] = nd2;
  Rank[nd2] += Rank[nd1];
}
int main() {
  scanf("%d%d", &N, &M);
  for (auto i = 1; i != N + 1 - 2 * (1 > N); i += 1 - 2 * (1 > N)) {
    scanf("%d", &animals[i].first);
    animals[i].second = i;
  }
  for (auto i = 0 - (0 > M); i != M - (0 > M); i += 1 - 2 * (0 > M)) {
    scanf("%d%d", &X, &Y);
    graph[X].push_back(Y);
    graph[Y].push_back(X);
  }
  sort(animals + 1, animals + N + 1, greater<pair<int, int>>());
  memset(availabe, false, sizeof(availabe));
  for (auto i = 1; i != N + 1 - 2 * (1 > N); i += 1 - 2 * (1 > N)) {
    Parent[i] = i;
    Rank[i] = 1;
  }
  for (auto i = 1; i != N + 1 - 2 * (1 > N); i += 1 - 2 * (1 > N)) {
    int node = animals[i].second;
    int anim = animals[i].first;
    availabe[node] = true;
    for (auto i = 0 - (0 > graph[node].size());
         i != graph[node].size() - (0 > graph[node].size());
         i += 1 - 2 * (0 > graph[node].size())) {
      int conn_node = graph[node][i];
      if (!availabe[conn_node]) continue;
      int Pa = find_parent(node);
      int Pb = find_parent(conn_node);
      if (Pa != Pb) {
        counts += (double)Rank[Pa] * (double)Rank[Pb] * (double)anim * 2.0;
        Union(Pa, Pb);
      }
    }
  }
  counts /= (double)N * ((double)N - 1.0);
  printf("%.10f\n", counts);
  return 0;
}
