#include <bits/stdc++.h>
using namespace std;
struct Edge {
  int u, v;
} e[1000010];
int gro[1000010];
int n, m, K;
void read_data() {
  scanf("%d %d %d", &n, &m, &K);
  for (int i = 1; i <= n; i++) scanf("%d", &gro[i]);
  for (int i = 1; i <= m; i++) scanf("%d %d", &e[i].u, &e[i].v);
}
bool mk[1000010];
int gp[1000010], rk[1000010], cnt[1000010], calc[1000010], hah[1000010];
int asd;
int find_gp(int x) {
  if (x == gp[x]) {
    return x;
  }
  int ret = find_gp(gp[x]);
  cnt[x] = cnt[gp[x]] ^ calc[x];
  return ret;
}
int lk[1000010];
bool Merge(int x, int y) {
  int a = find_gp(x), b = find_gp(y);
  if (a == b) return 0;
  if (rk[a] < rk[b]) swap(a, b), swap(x, y);
  gp[b] = a;
  calc[b] = cnt[a] ^ cnt[x] ^ 1 ^ cnt[y] ^ cnt[b];
  hah[b] = rk[a];
  rk[a] = max(rk[a], rk[b] + 1);
  lk[++lk[0]] = b;
  return 1;
}
void work_one_group() {
  for (int i = 1; i <= n; i++) {
    gp[i] = i;
    rk[i] = 1;
    cnt[i] = 1;
    calc[i] = 0;
  }
  for (int i = 1; i <= m; i++) {
    int u = e[i].u, v = e[i].v;
    if (gro[u] != gro[v]) continue;
    bool JJ = Merge(u, v);
    if (!JJ && (cnt[u] + cnt[v]) % 2 == 0) {
      mk[gro[find_gp(u)]] = 1;
    }
  }
}
Edge q[1000010];
int head;
bool cmp(Edge &a, Edge &b) {
  int p1 = gro[a.u], p2 = gro[a.v];
  int q1 = gro[b.u], q2 = gro[b.v];
  if (p1 > p2) swap(p1, p2);
  if (q1 > q2) swap(q1, q2);
  if (p1 == q1) return p2 < q2;
  return p1 < q1;
}
long long ans;
void check_out(int l, int r) {
  lk[0] = 0;
  for (int i = l; i <= r; i++) {
    int u = q[i].u, v = q[i].v;
    bool JJ = Merge(u, v);
    if (!JJ && ((cnt[u] + cnt[v]) % 2 == 0)) {
      ans--;
      break;
    }
  }
  for (int i = 1; i <= lk[0]; i++) {
    rk[gp[lk[i]]] = hah[lk[i]];
    gp[lk[i]] = lk[i];
  }
}
bool equal(Edge &a, Edge &b) {
  return ((gro[a.u] == gro[b.u] && gro[a.v] == gro[b.v]) ||
          (gro[a.u] == gro[b.v] && gro[a.v] == gro[b.u]));
}
void work_g2g() {
  long long tot = 0;
  for (int i = 1; i <= K; i++) {
    if (!mk[i]) tot++;
  }
  for (int i = 1; i <= m; i++) {
    int u = e[i].u, v = e[i].v;
    if (gro[u] == gro[v]) continue;
    if (mk[gro[u]] || mk[gro[v]]) continue;
    q[++head] = e[i];
  }
  sort(q + 1, q + head + 1, cmp);
  ans = tot * (tot - 1) / 2;
  int l = 1;
  for (int i = 1; i <= head; i++) {
    if (i == head || (!equal(q[i], q[i + 1]))) {
      check_out(l, i);
      l = i + 1;
    }
  }
  printf("%lld\n", ans);
}
int main() {
  read_data();
  work_one_group();
  work_g2g();
}
