#include <bits/stdc++.h>
using namespace std;
struct edge {
  int to, nxxt;
} e[500005 << 1];
int n, m, k, a[500005], b[500005][2], head[500005],
    cnt = 1, co[500005], f[500005], dis[500005], dep[500005], id[500005];
int stk[500005][3], tot;
bool ban[500005], leg[500005];
queue<int> q;
inline void ins(int u, int v) {
  e[cnt].to = v;
  e[cnt].nxxt = head[u];
  head[u] = cnt++;
}
inline void rd(int &x) {
  x = 0;
  register char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - 48;
    c = getchar();
  }
}
pair<int, int> getroot(int t) {
  if (f[t] == -1) return make_pair(t, 0);
  pair<int, int> ret = getroot(f[t]);
  ret.second ^= dis[t];
  return ret;
}
void bfs(int x) {
  q.push(x);
  while (!q.empty()) {
    int a1 = q.front();
    q.pop();
    for (int i = head[a1]; i; i = e[i].nxxt) {
      int t1 = e[i].to;
      if (a[a1] ^ a[t1]) continue;
      if (co[t1] == -1) {
        co[t1] = co[a1] ^ 1;
        q.push(t1);
      } else {
        if (co[a1] == co[t1]) ban[a[x]] = 1;
      }
    }
  }
}
bool cmp(int x, int y) {
  if (a[b[x][0]] ^ a[b[y][0]])
    return a[b[x][0]] < a[b[y][0]];
  else
    return a[b[x][1]] < a[b[y][1]];
}
int main() {
  rd(n), rd(m), rd(k);
  for (int i = 1; i <= n; i++) rd(a[i]);
  for (int i = 1; i <= m; i++)
    rd(b[i][0]), rd(b[i][1]), ins(b[i][0], b[i][1]), ins(b[i][1], b[i][0]);
  memset(co, -1, sizeof(co));
  for (int i = 1; i <= n; i++)
    if (co[i] == -1) {
      co[i] = 0;
      bfs(i);
    }
  int ctt = k;
  for (int i = 1; i <= k; i++)
    if (ban[i]) ctt--;
  long long ans = 1ll * ctt * (ctt - 1) / 2;
  memset(f, -1, sizeof(f));
  for (int i = 1; i <= m; i++) {
    id[i] = i;
    if (ban[a[b[i][0]]]) continue;
    if (ban[a[b[i][1]]]) continue;
    if (a[b[i][0]] == a[b[i][1]]) {
      pair<int, int> p1 = getroot(b[i][0]);
      pair<int, int> p2 = getroot(b[i][1]);
      if (p1.first == p2.first) continue;
      if (dep[p1.first] > dep[p2.first]) swap(p1, p2);
      f[p1.first] = p2.first;
      dis[p1.first] = p1.second ^ p2.second ^ 1;
      if (dep[p1.first] == dep[p2.first]) dep[p2.first]++;
    } else {
      if (a[b[i][0]] > a[b[i][1]]) swap(b[i][0], b[i][1]);
      leg[i] = 1;
    }
  }
  sort(id + 1, id + 1 + m, cmp);
  for (int i = 1; i <= m; i++) {
    int x = id[i];
    if (!leg[x]) continue;
    int j = i;
    while (j <= m &&
           ((a[b[x][0]] == a[b[id[j]][0]] && a[b[x][1]] == a[b[id[j]][1]]) ||
            !leg[id[j]]))
      j++;
    j--;
    int tcn = 0;
    bool flag = true;
    for (int ii = i; ii <= j; ii++) {
      x = id[ii];
      if (!leg[x]) continue;
      pair<int, int> p1 = getroot(b[x][0]), p2 = getroot(b[x][1]);
      if (p1.first == p2.first) {
        if (p1.second == p2.second) {
          flag = false;
          break;
        }
      } else {
        if (dep[p1.first] > dep[p2.first]) swap(p1, p2);
        stk[++tot][0] = p1.first, stk[tot][1] = p2.first;
        f[p1.first] = p2.first;
        dis[p1.first] = p1.second ^ p2.second ^ 1;
        if (dep[p1.first] == dep[p2.first]) dep[p2.first]++, stk[tot][2] = 1;
        tcn++;
      }
    }
    i = j;
    if (!flag) ans--;
    for (int ii = 0; ii < tcn; ii++) {
      f[stk[tot][0]] = -1;
      if (stk[tot][2]) dep[stk[tot][1]]--;
      tot--;
    }
  }
  printf("%lld\n", ans);
}
