#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int data = 0, w = 1;
  char ch = 0;
  while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
  if (ch == '-') w = -1, ch = getchar();
  while (ch >= '0' && ch <= '9') data = data * 10 + ch - '0', ch = getchar();
  return data * w;
}
int n, m, f[1000005], s[1000005], co, up[1000005];
int gf(int x) {
  while (x != f[x]) x = f[x];
  return x;
}
int getco(int x) {
  int co = 0;
  while (x != f[x]) co ^= up[x], x = f[x];
  return co;
}
struct Stack {
  int x, y;
} st[1000005];
int top;
void Back(int tp) {
  while (top != tp) {
    int x = st[top].x, y = st[top].y;
    f[y] = y;
    s[x] -= s[y];
    top--;
  }
}
int Merge(int x, int y) {
  if (gf(x) == gf(y)) return getco(x) == getco(y);
  int C1 = getco(x), C2 = getco(y);
  x = gf(x), y = gf(y);
  if (s[x] < s[y]) swap(x, y);
  f[y] = x;
  s[x] += s[y];
  up[y] = C1 ^ C2 ^ 1;
  st[++top] = (Stack){x, y};
  return 0;
}
int Mar[1000005], K, c[1000005];
struct edge {
  int x, y;
} e[1000005];
int main() {
  n = read(), m = read(), K = read();
  for (int i = 1; i <= n; i++) c[i] = read(), f[i] = i, s[i] = 1;
  int mm = m;
  m = 0;
  for (int i = 1; i <= mm; i++) {
    int x = read(), y = read();
    if (c[x] > c[y]) swap(x, y);
    if (c[x] == c[y])
      Mar[c[x]] |= Merge(x, y);
    else
      e[++m] = (edge){x, y};
  }
  sort(e + 1, e + m + 1, [](edge A, edge B) {
    return c[A.x] != c[B.x] ? c[A.x] < c[B.x] : c[A.y] < c[B.y];
  });
  long long Ans = 0;
  for (int i = 1; i <= K; i++) Ans += Mar[i] ^ 1;
  Ans = Ans * (Ans - 1) >> 1;
  for (int i = 1, j; i <= m; i = j) {
    j = i;
    while (c[e[j].x] == c[e[i].x] && c[e[j].y] == c[e[i].y]) ++j;
    if (Mar[c[e[i].x]] || Mar[c[e[i].y]]) continue;
    int pt = top, flag = 0;
    for (int k = i; k < j; k++) {
      flag |= Merge(e[k].x, e[k].y);
    }
    Back(pt);
    Ans -= flag;
  }
  cout << Ans << '\n';
  return 0;
}
