#include <bits/stdc++.h>
using std::cin;
using std::cout;
struct Item {
  int parent;
  int count;
};
int Find(int x, std::vector<Item>* items) {
  if (items->at(x).parent == x) {
    return x;
  }
  return items->at(x).parent = Find(items->at(x).parent, items);
}
void Unite(int x, int y, std::vector<Item>* items) {
  assert(x == Find(x, items));
  assert(y == Find(y, items));
  if (items->at(x).count < items->at(y).count) {
    std::swap(x, y);
  }
  items->at(y).parent = x;
  items->at(x).count += items->at(y).count;
}
int main() {
  std::ios_base::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  std::vector<std::pair<int, int>> A(N);
  std::vector<Item> items(N);
  for (int i = 0; i < N; ++i) {
    int a;
    cin >> a;
    A[i].first = a;
    A[i].second = i;
    items[i].parent = i;
    items[i].count = 1;
  }
  std::vector<std::vector<int>> gr(N);
  for (int i = 0; i < M; ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    gr[a].push_back(b);
    gr[b].push_back(a);
  }
  std::sort(A.begin(), A.end());
  int64_t answer = 0;
  std::vector<int> visited(N, false);
  for (int index = N - 1; index >= 0; --index) {
    int value = A[index].first;
    int vertex = A[index].second;
    int64_t sum = 0, sum_sq = 0;
    for (int neib : gr[vertex]) {
      int x = Find(vertex, &items);
      int y = Find(neib, &items);
      if (x == y) {
        continue;
      }
      if (!visited[y]) {
        continue;
      }
      sum += items[y].count;
      sum_sq += (int64_t)items[y].count * items[y].count;
      Unite(x, y, &items);
    }
    answer += (int64_t)value * (sum * sum - sum_sq + 2 * sum);
    visited[Find(vertex, &items)] = true;
  }
  long double result = (long double)answer / ((int64_t)N * (N - 1));
  cout.precision(6);
  cout << std::fixed << result << '\n';
  return 0;
}
