#include <bits/stdc++.h>
using namespace std;
const int N = 500005;
struct Edge {
  int vet1, vet2, c1, c2;
  long long val;
} e[N];
int n, m, k, x, y, c[N], Num = 0;
int cnt, fa[N << 1];
bool Flag[N];
stack<pair<int, int> > sta;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
inline bool mycmp(Edge a, Edge b) { return a.val < b.val; }
inline long long find(int x) {
  int Now = x, cnt = 0;
  while (fa[Now] != Now) {
    ++cnt;
    Now = fa[Now];
  }
  long long ans = (long long)cnt * N + Now;
  if (cnt % 2 == 0) x = fa[x], --cnt;
  while (cnt > 18) {
    int i = fa[x];
    fa[x] = Now;
    x = fa[i];
    cnt -= 2;
  }
  return ans;
}
inline bool Union(int x, int y) {
  long long fx = find(x), fy = find(y);
  int disx = fx % N, disy = fy % N;
  int cx = fx / N, cy = fy / N;
  if (disx == disy) {
    return (cx + cy) % 2 == 1;
  } else {
    sta.push(pair<int, int>(disx, fa[disx]));
    if ((cx + cy) % 2)
      fa[disx] = ++n, fa[n] = disy;
    else
      fa[disx] = disy;
    return true;
  }
}
inline void Undo() {
  while (!sta.empty()) {
    pair<int, int> pr = sta.top();
    sta.pop();
    fa[pr.first] = pr.second;
  }
}
int main() {
  n = read(), m = read(), k = read();
  for (int i = 1; i <= n; i++) c[i] = read();
  for (int i = 1; i <= m + n; i++) fa[i] = i;
  cnt = k;
  for (int i = 0; i < m; i++) {
    x = read(), y = read();
    if (c[x] == c[y]) {
      if (!Union(x, y) && !Flag[c[x]]) {
        --cnt;
        Flag[c[x]] = 1;
      }
    } else {
      e[Num].vet1 = x;
      e[Num].vet2 = y;
      e[Num].c1 = min(c[x], c[y]);
      e[Num].c2 = max(c[x], c[y]);
      e[Num].val = (long long)e[Num].c1 * N + e[Num].c2;
      Num++;
    }
  }
  sort(e, e + Num, mycmp);
  while (!sta.empty()) sta.pop();
  long long ans = (long long)cnt * (cnt - 1) / 2;
  bool flag = 0;
  for (int i = 0; i < Num; i++) {
    x = e[i].vet1, y = e[i].vet2;
    if (Flag[c[x]] || Flag[c[y]]) continue;
    if (i > 0 && e[i].val != e[i - 1].val) {
      flag = 0;
      Undo();
    }
    if (!Union(x, y)) {
      if (!flag) --ans;
      flag = 1;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
