#include <bits/stdc++.h>
using namespace std;
struct edg {
  int from, to, next;
} b[500000 * 2 + 5], ob[500000 + 5], nb[500000 * 10 + 5];
int g[500000 + 5], cntb, n, m, k, group[500000 + 5], dis[500000 + 5], cntg,
    cnte, belong[500000 + 5], ndis[500000 * 2 + 5];
int ng[500000 * 2 + 5], cntn;
long long ans;
bool ise[500000 + 5], chan[500000 + 5];
map<int, int> bh[500000 + 5];
map<int, int> xbh[500000 + 5];
set<int> ce[500000 + 5];
vector<int> bigb[500000 + 5];
vector<int> ning[500000 + 5];
void ade(int fr, int to) {
  b[++cntb] = {fr, to, g[fr]};
  g[fr] = cntb;
}
void ade2(int fr, int to) {
  nb[++cntn] = {fr, to, ng[fr]};
  ng[fr] = cntn;
}
bool ok;
void dfs(int now) {
  for (int i = g[now]; i; i = b[i].next) {
    if (group[b[i].to] != group[now]) continue;
    if (dis[b[i].to] == -1)
      dis[b[i].to] = dis[now] ^ 1, belong[b[i].to] = belong[now], dfs(b[i].to);
    else if (dis[b[i].to] != (dis[now] ^ 1)) {
      ok = false;
      return;
    }
    if (!ok) return;
  }
}
void dfs2(int now) {
  for (int i = ng[now]; i; i = nb[i].next) {
    if (ndis[nb[i].to] == -1)
      ndis[nb[i].to] = ndis[now] ^ 1, dfs2(nb[i].to);
    else if (ndis[nb[i].to] != (ndis[now] ^ 1)) {
      ok = false;
      return;
    }
    if (!ok) return;
  }
}
void recov(int now) {
  ndis[now] = -1;
  for (int i = ng[now]; i; i = nb[i].next)
    if (~ndis[nb[i].to]) recov(nb[i].to);
}
bool pd(int now) {
  ok = true;
  for (int i = 0; i < bigb[now].size(); i++) {
    int xi = ob[bigb[now][i]].from, yi = ob[bigb[now][i]].to;
    if (!ise[group[xi]] || !ise[group[yi]]) return false;
    int bx = belong[xi], by = belong[yi];
    ade2(bx + dis[xi] * 500000, by + dis[yi] * 500000);
    ade2(by + dis[yi] * 500000, bx + dis[xi] * 500000);
    ade2(bx, bx + 500000), ade2(bx + 500000, bx);
    ade2(by, by + 500000), ade2(by + 500000, by);
  }
  for (int i = 0; i < bigb[now].size(); i++) {
    int xi = ob[bigb[now][i]].from, yi = ob[bigb[now][i]].to;
    int bx = belong[xi], by = belong[yi];
    if (ndis[bx + dis[xi] * 500000] == -1)
      ndis[bx + dis[xi] * 500000] = 0, dfs2(bx + dis[xi] * 500000);
    if (ndis[by + dis[yi] * 500000] == -1)
      ndis[by + dis[yi] * 500000] = 0, dfs2(by + dis[yi] * 500000);
  }
  for (int i = 0; i < bigb[now].size(); i++) {
    int xi = ob[bigb[now][i]].from, yi = ob[bigb[now][i]].to;
    int bx = belong[xi], by = belong[yi];
    if (~ndis[bx + dis[xi] * 500000]) recov(bx + dis[xi] * 500000);
    if (~ndis[by + dis[yi] * 500000]) recov(by + dis[yi] * 500000);
  }
  for (int i = 0; i < bigb[now].size(); i++) {
    int xi = ob[bigb[now][i]].from, yi = ob[bigb[now][i]].to;
    int bx = belong[xi], by = belong[yi];
    ng[bx + 500000] = ng[bx] = ng[by] = ng[by + 500000] = 0;
  }
  cntn = 0;
  return ok;
}
int main() {
  memset(dis, -1, sizeof(dis));
  memset(ndis, -1, sizeof(ndis));
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &group[i]);
    ning[group[i]].push_back(i);
  }
  for (int i = 1, xi, yi; i <= m; i++) {
    scanf("%d%d", &xi, &yi);
    ade(xi, yi), ade(yi, xi);
    if (group[xi] > group[yi]) swap(xi, yi);
    ob[i].from = xi, ob[i].to = yi;
    int gx = group[xi], gy = group[yi];
    if (gx == gy) continue;
    if (bh[gx].find(gy) == bh[gx].end()) bh[gx][gy] = ++cntg;
    bigb[bh[gx][gy]].push_back(i);
  }
  for (int i = 1; i <= k; i++) {
    ise[i] = true;
    if (ning[i].size()) {
      for (int j = 0; j < ning[i].size(); j++)
        if (dis[ning[i][j]] == -1) {
          ok = true;
          dis[ning[i][j]] = 0;
          belong[ning[i][j]] = ++belong[0];
          dfs(ning[i][j]);
          if (!ok) ise[i] = false;
        }
    }
    if (ise[i]) ++cnte;
  }
  for (int i = 1, xi, yi; i <= m; i++) {
    xi = ob[i].from, yi = ob[i].to;
    int gx = group[xi], gy = group[yi];
    if (!ise[gx] || !ise[gy] || gx == gy) continue;
    ce[gx].insert(gy), ce[gy].insert(gx);
  }
  if (cnte) {
    for (int i = 1; i <= k; i++)
      if (ise[i]) ans += cnte - 1 - (int)ce[i].size();
  }
  ans >>= 1;
  for (int i = 1; i <= cntg; i++)
    if (pd(i)) ++ans;
  printf("%lld", ans);
  return 0;
}
