#include <bits/stdc++.h>
using namespace std;
typedef struct {
  int u, v, cu, cv;
} Edge;
const int N = 500010, M = 1000010;
pair<int, int> stk[M];
int top;
Edge e[N];
int cnt;
int fa[M];
int co[N];
int sz[M];
int st[N];
int n, m, k;
int find(int x) {
  if (x == fa[x])
    return x;
  else
    return find(fa[x]);
}
void merge(int u, int v) {
  int fu = find(u), fv = find(v);
  if (sz[fu] > sz[fv]) swap(fu, fv);
  stk[++top] = {fu, fv};
  fa[fu] = fv;
  sz[fv] += sz[fu];
}
int cmp(Edge a, Edge b) {
  if (a.cu == b.cu)
    return a.cv < b.cv;
  else
    return a.cu < b.cu;
}
void undo() {
  pair<int, int> t = stk[top--];
  fa[t.first] = t.first;
  sz[t.second] -= sz[t.first];
}
int main() {
  cin >> n >> m >> k;
  for (int i = 1; i <= n + n; i++) sz[i] = 1, fa[i] = i;
  for (int i = 1; i <= n; i++) cin >> co[i];
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    if (co[u] == co[v]) {
      int fu = find(u), fv = find(v);
      if (fu == fv) {
        st[co[u]] = 1;
      } else {
        int fuu = find(u + n), fvv = find(v + n);
        merge(fu, fvv), merge(fv, fuu);
      }
    } else {
      e[++cnt] = {u, v, min(co[u], co[v]), max(co[v], co[u])};
    }
  }
  long long aa = 0;
  for (int i = 1; i <= k; i++)
    if (!st[i]) aa++;
  long long ans = aa * (aa - 1) / 2;
  sort(e + 1, e + 1 + cnt, cmp);
  int idx = top;
  int flag = 0;
  for (int i = 1; i <= cnt; i++) {
    if (e[i].cv != e[i - 1].cv || e[i].cu != e[i - 1].cu) {
      flag = 0;
      while (idx != top) undo();
    }
    if (st[e[i].cv] || st[e[i].cu]) continue;
    if (flag) continue;
    int fu = find(e[i].u), fv = find(e[i].v);
    if (fu == fv) {
      ans--;
      flag = 1;
      continue;
    }
    int fuu = find(e[i].u + n), fvv = find(e[i].v + n);
    merge(fu, fvv), merge(fv, fuu);
  }
  cout << ans << endl;
  return 0;
}
