#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
int hd[1000007], pre[4000007], to[4000007], num;
vector<int> E[1000007];
bool del[1000007];
void adde(int x, int y) {
  num++;
  pre[num] = hd[x];
  hd[x] = num;
  to[num] = y;
}
int bl[1000007], cl[1000007], tl[1000007];
bool dfs(int v, int c) {
  if (cl[v] != -1) {
    return cl[v] == c;
  }
  cl[v] = c;
  for (int i = hd[v]; i; i = pre[i]) {
    int u = to[i];
    if (!dfs(u, c ^ 1)) return false;
  }
  return true;
}
bool dfs1(int v, int c) {
  if (tl[v] != -1) {
    return tl[v] == c;
  }
  tl[v] = c;
  for (auto u : E[v]) {
    if (!dfs1(u, c ^ 1)) return false;
  }
  return true;
}
void clear(int v) {
  tl[v] = -1;
  for (auto u : E[v]) {
    if (tl[u] != -1) clear(u);
  }
}
map<pair<int, int>, vector<int> > mp;
struct edge {
  int x, y;
} e[1000007];
int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &bl[i]);
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    e[i] = {x, y};
    if (bl[x] == bl[y]) {
      adde(x, y), adde(y, x);
    } else {
      int u = bl[x], v = bl[y];
      if (u > v) swap(u, v);
      mp[make_pair(u, v)].push_back(i);
    }
  }
  int tt = 0;
  memset(cl, -1, sizeof(cl));
  memset(tl, -1, sizeof(tl));
  for (int i = 1; i <= n; i++)
    if (cl[i] == -1) {
      if (!dfs(i, tt)) {
        del[bl[i]] = 1;
      }
      E[tt].push_back(tt ^ 1), E[tt ^ 1].push_back(tt);
      tt += 2;
    }
  int cnt = 0;
  for (int i = 1; i <= k; i++)
    if (!del[i]) cnt++;
  long long ans = 1ll * cnt * (cnt - 1) / 2;
  vector<int> S;
  for (auto te : mp) {
    vector<int> a = te.second;
    int s1 = te.first.first, s2 = te.first.second;
    if (del[s1] || del[s2]) continue;
    for (auto i : a) {
      int x = cl[e[i].x], y = cl[e[i].y];
      S.push_back(x), S.push_back(y);
      E[x].push_back(y), E[y].push_back(x);
    }
    bool flag = 1;
    for (auto v : S)
      if (tl[v] == -1) {
        if (!dfs1(v, 0)) flag = 0;
      }
    if (!flag) ans--;
    for (auto v : S)
      if (tl[v] != -1) clear(v);
    for (auto v : S) E[v].resize(1);
    S.clear();
  }
  printf("%lld\n", ans);
  return 0;
}
