#include <bits/stdc++.h>
using namespace std;
void RD(int &x) { scanf("%d", &x); }
void RD(long long &x) { scanf("%I64d", &x); }
void RD(unsigned long long &x) { scanf("%I64u", &x); }
void RD(unsigned int &x) { scanf("%u", &x); }
void RD(double &x) { scanf("%lf", &x); }
void RD(int &x, int &y) { scanf("%d%d", &x, &y); }
void RD(long long &x, long long &y) { scanf("%I64d%I64d", &x, &y); }
void RD(unsigned int &x, unsigned int &y) { scanf("%u%u", &x, &y); }
void RD(double &x, double &y) { scanf("%lf%lf", &x, &y); }
void RD(int &x, int &y, int &z) { scanf("%d%d%d", &x, &y, &z); }
void RD(long long &x, long long &y, long long &z) {
  scanf("%I64d%I64d%I64d", &x, &y, &z);
}
void RD(unsigned int &x, unsigned int &y, unsigned int &z) {
  scanf("%u%u%u", &x, &y, &z);
}
void RD(double &x, double &y, double &z) { scanf("%lf%lf%lf", &x, &y, &z); }
void RD(char &x) { x = getchar(); }
void RD(char *s) { scanf("%s", s); }
void RD(string &s) { cin >> s; }
void PR(int x) { printf("%d\n", x); }
void PR(int x, int y) { printf("%d %d\n", x, y); }
void PR(long long x) { printf("%I64d\n", x); }
void PR(unsigned int x) { printf("%u\n", x); }
void PR(unsigned long long x) { printf("%I64u\n", x); }
void PR(double x) { printf("%.4lf\n", x); }
void PR(char x) { printf("%c\n", x); }
void PR(char *x) { printf("%s\n", x); }
void PR(string x) { cout << x << endl; }
void upMin(int &x, int y) {
  if (x > y) x = y;
}
void upMin(long long &x, long long y) {
  if (x > y) x = y;
}
void upMin(double &x, double y) {
  if (x > y) x = y;
}
void upMax(int &x, int y) {
  if (x < y) x = y;
}
void upMax(long long &x, long long y) {
  if (x < y) x = y;
}
void upMax(double &x, double y) {
  if (x < y) x = y;
}
int sgn(double x) {
  if (x > 1e-6) return 1;
  if (x < -1e-6) return -1;
  return 0;
}
long long Gcd(long long x, long long y) {
  if (y == 0) return x;
  return Gcd(y, x % y);
}
long long Lcm(long long x, long long y) { return x / Gcd(x, y) * y; }
long long eular(long long n) {
  long long ans = n, i;
  for (i = 2; i * i <= n; i++)
    if (n % i == 0) {
      ans -= ans / i;
      while (n % i == 0) n /= i;
    }
  if (n > 1) ans -= ans / n;
  return ans;
}
long long exGcd(long long a, long long b, long long &x, long long &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  long long temp = exGcd(b, a % b, x, y);
  long long t = x;
  x = y;
  y = t - a / b * y;
  return temp;
}
long long gcdReverse(long long a, long long b) {
  long long x, y;
  exGcd(a, b, x, y);
  x %= b;
  if (x < 0) x += b;
  return x;
}
long long myPow(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a;
    a = a * a;
    b >>= 1;
  }
  return ans;
}
long long myPow(long long a, long long b, long long mod) {
  a %= mod;
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return ans;
}
int getInt() {
  int x = 0;
  char c = getchar();
  while (!isdigit(c)) c = getchar();
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x;
}
int getBitOfOne(long long x) {
  int ans = 0;
  while (x) ans += x & 1, x >>= 1;
  return ans;
}
long long getSqrt(long long t) {
  long long p = sqrt(1.0 * t);
  while (p * p > t) p--;
  while ((p + 1) <= t / (p + 1)) p++;
  return p;
}
const int mod = 300007;
const long long inf = (((long long)1) << 60) + 5;
const double dinf = 1000000000;
const int INF = 2000000005;
const int N = 200005;
int n, m;
long long a[N];
vector<int> g[N];
int S[N];
struct node {
  int u, v, t;
  void get() {
    RD(u, v);
    t = 0;
    if (a[u] > a[v]) swap(u, v);
  }
};
node b[N], c[N];
int cmp(node p, node q) {
  if (a[p.u] != a[q.u]) return a[p.u] < a[q.u];
  return a[p.v] < a[q.v];
}
int cmp1(node p, node q) {
  return ((a[p.u]) < (a[p.v]) ? (a[p.u]) : (a[p.v])) >
         ((a[q.u]) < (a[q.v]) ? (a[q.u]) : (a[q.v]));
}
int get(int x) {
  if (S[x] != x) S[x] = get(S[x]);
  return S[x];
}
int size[N], val[N];
int main() {
  RD(n, m);
  int i;
  for (i = 1; i <= n; i++) RD(a[i]);
  for (i = 1; i <= m; i++) b[i].get();
  sort(b + 1, b + m + 1, cmp1);
  for (i = 1; i <= n; i++) S[i] = i, size[i] = 1;
  long long ans = 0;
  for (i = 1; i <= m; i++) {
    int u = b[i].u;
    int v = b[i].v;
    int X = ((a[u]) < (a[v]) ? (a[u]) : (a[v]));
    u = get(u);
    v = get(v);
    if (u == v) continue;
    ans += (long long)size[u] * size[v] * X;
    size[u] += size[v];
    S[v] = u;
  }
  ans <<= 1;
  double p = 1.0 * ans / ((long long)n * (n - 1));
  printf("%.6lf\n", p);
}
