#include <bits/stdc++.h>
using namespace std;
const int maxn = 555555;
int c[maxn];
long long ans;
struct NODE {
  int a, b, ba, bb;
  NODE(int a1 = 0, int a2 = 0, int a3 = 0, int a4 = 0)
      : a(a1), b(a2), ba(a3), bb(a4) {}
  bool operator<(const NODE x) const {
    if (make_pair(ba, bb) == make_pair(x.ba, x.bb))
      return make_pair(a, b) < make_pair(x.a, x.b);
    return make_pair(ba, bb) < make_pair(x.ba, x.bb);
  }
} P[maxn * 2];
vector<int> V[maxn];
int fa[maxn], col[maxn], ok[maxn], inv[maxn], vis[maxn];
vector<int> fav[maxn];
int n, m, k, tot;
bool dfsok;
void dfs(int u, int f) {
  fa[u] = f;
  vis[u] = 1;
  for (int v : V[u]) {
    if (dfsok == 0) break;
    if (vis[v]) {
      if (col[v] == col[u]) {
        dfsok = 0;
        return;
      }
    } else {
      col[v] = col[u] ^ 1;
      dfs(v, f);
    }
  }
}
void init() {
  for (int i = 0; i < n; ++i)
    if (!vis[i]) {
      dfsok = 1;
      dfs(i, i);
      fav[c[i]].push_back(i);
      if (dfsok == 0) ok[c[i]] = 1;
    }
}
int dfn = 10;
void cal(int L, int R) {
  if (ok[c[P[L].a]] || ok[c[P[L].b]]) {
    return;
  }
  for (int i = L; i <= R; i += 2) {
    P[i].ba = fa[P[i].a];
    P[i].bb = fa[P[i].b];
    swap(P[i + 1].a, P[i + 1].b);
    P[i + 1].ba = fa[P[i + 1].a];
    P[i + 1].bb = fa[P[i + 1].b];
  }
  sort(P + L, P + R + 1);
  dfn++;
  bool dok = 1;
  function<void(int)> ddfs = [&](int x) {
    int l = lower_bound(P + L, P + R + 1, NODE(0, 0, x, 0)) - P;
    int r = upper_bound(P + L, P + R + 1, NODE(0, 0, x, 1e9)) - P;
    vis[x] = dfn;
    for (int i = l; i < r && dok; ++i) {
      int u = P[i].a, v = P[i].b, uf = P[i].ba, vf = P[i].bb;
      if (vis[vf] == dfn) {
        if ((col[u] ^ inv[uf]) == (col[v] ^ inv[vf])) {
          dok = 0;
          return;
        }
      } else {
        if ((col[u] ^ inv[uf]) == (col[v] ^ inv[vf])) inv[vf] ^= 1;
        ddfs(vf);
      }
    }
  };
  for (int v : fav[c[P[L].b]])
    if (vis[v] != dfn) {
      ddfs(v);
      if (!dok) break;
    }
  if (dok == 0) ans--;
}
int main() {
  ios_base::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  cin >> n >> m >> k;
  for (int i = 0; i < n; ++i) cin >> c[i];
  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    --v;
    --u;
    if (c[v] == c[u]) {
      V[u].push_back(v);
      V[v].push_back(u);
    } else {
      if (c[v] < c[u]) swap(u, v);
      P[tot++] = NODE(u, v, c[u], c[v]);
      P[tot++] = NODE(u, v, c[u], c[v]);
    }
  }
  init();
  sort(P, P + tot);
  int okc = 0;
  for (int i = 1; i <= k; ++i) okc += !ok[i];
  ans = 1ll * (okc - 1) * okc / 2;
  for (int i = 0; i < tot;) {
    int j = i;
    while (i < tot && P[i].ba == P[j].ba && P[i].bb == P[j].bb) {
      ++i;
    }
    cal(j, i - 1);
  }
  cout << ans << "\n";
  return 0;
}
