#include <bits/stdc++.h>
using namespace std;
const int maxn = 500005;
int n, m, k, c[maxn], nok[maxn];
vector<int> g[maxn], p[maxn];
struct Union_Set {
  int fa[maxn], val[maxn], siz[maxn], x_[maxn], y_[maxn], z_[maxn], tot;
  inline int find(int x) {
    while (x != fa[x]) x = fa[x];
    return x;
  }
  inline int getdis(int x) {
    int ans = 0;
    for (; x != fa[x]; x = fa[x]) ans ^= val[x];
    return ans;
  }
  inline bool merge(int x, int y) {
    int u = find(x), v = find(y);
    if (u == v) return true;
    if (siz[u] < siz[v]) swap(u, v), swap(x, y);
    x_[++tot] = u, y_[tot] = v, z_[tot] = getdis(x) ^ getdis(y) ^ 1;
    fa[v] = u, val[v] ^= z_[tot], siz[u] += siz[v];
    return false;
  }
  inline void cancel() {
    for (; tot; tot--) {
      fa[y_[tot]] = y_[tot];
      val[y_[tot]] ^= z_[tot];
      siz[x_[tot]] -= siz[y_[tot]];
    }
  }
} S;
template <typename T>
inline void read(T &x) {
  static char ch;
  bool f = 1;
  for (x = 0, ch = getchar(); !isdigit(ch); ch = getchar())
    if (ch == '-') f = 0;
  for (; isdigit(ch); x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar())
    ;
  x = f ? x : -x;
}
inline bool cmp(const pair<int, int> &a, const pair<int, int> &b) {
  return c[a.first] < c[b.first];
}
int main() {
  read(n), read(m), read(k);
  for (int i = 1; i <= n; i++)
    read(c[i]), S.fa[i] = i, S.val[i] = 0, S.siz[i] = 1, p[c[i]].push_back(i);
  int x, y;
  for (int i = 1; i <= m; i++) {
    read(x), read(y);
    g[x].push_back(y);
    g[y].push_back(x);
    if (c[x] == c[y]) {
      if (S.merge(x, y) && S.getdis(x) == S.getdis(y)) nok[c[x]] = 1;
    }
  }
  S.tot = 0;
  int ansk = k;
  long long ans = 0;
  for (int i = 1; i <= k; i++) ansk -= nok[i];
  static pair<int, int> a[maxn];
  int cnt = 0;
  for (int i = 1; i <= k; i++) {
    if (p[i].empty()) {
      ans += ansk - 1;
      continue;
    }
    if (nok[i]) continue;
    cnt = 0;
    for (auto u : p[i])
      for (auto v : g[u])
        if (i != c[v] && !nok[c[v]]) a[++cnt] = pair<int, int>(v, u);
    sort(a + 1, a + cnt + 1, cmp);
    ans += ansk - 1;
    for (int l = 1, r = 0; l <= cnt; l = r + 1) {
      r = l;
      while (r < cnt && c[a[r + 1].first] == c[a[l].first]) r++;
      bool fl = 0;
      for (int i = l; i <= r; i++)
        if (S.merge(a[i].first, a[i].second) &&
            S.getdis(a[i].first) == S.getdis(a[i].second)) {
          fl = 1;
          break;
        }
      ans -= fl, S.cancel();
    };
  }
  printf("%lld\n", ans / 2);
  return 0;
}
