#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 10;
const int M = 6e5 + 10;
const int INF = 0x3f3f3f3f;
int n, m, k;
int p[N], d[N];
int st[N], ran[N], top, str[N];
int col[N], f[N];
int find(int x) {
  for (; x != p[x]; x = p[x])
    ;
  return x;
}
int getd(int x) {
  int ret = 0;
  for (; x != p[x]; ret ^= d[x], x = p[x])
    ;
  return ret;
}
void merge(int u, int v, int w) {
  ++top;
  if (ran[u] < ran[v]) swap(u, v);
  if (ran[u] == ran[v])
    ++ran[u], str[top] = u;
  else
    str[top] = 0;
  st[top] = v;
  p[v] = u;
  d[v] = w;
}
void clr() {
  if (str[top]) --ran[str[top]];
  p[st[top]] = st[top];
  d[st[top]] = 0;
  --top;
}
inline int read() {
  char ch = getchar();
  int x = 0, f = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) - '0' + ch;
    ch = getchar();
  }
  return x * f;
}
pair<int, int> e[M];
map<pair<int, int>, int> ma;
int cnt;
vector<int> g[N];
int main() {
  n = read(), m = read(), k = read();
  for (int i = 1; i <= n; i++) col[i] = read(), p[i] = i;
  for (int i = 1; i <= m; i++) e[i].first = read(), e[i].second = read();
  for (int i = 1; i <= m; i++) {
    if (col[e[i].first] == col[e[i].second]) {
      int u = find(e[i].first), v = find(e[i].second);
      int w = getd(e[i].first) ^ getd(e[i].second) ^ 1;
      if (u != v)
        merge(u, v, w);
      else if (w & 1)
        f[col[e[i].first]] = 1;
    }
  }
  for (int i = 1; i <= m; i++) {
    if (col[e[i].first] != col[e[i].second] && !f[col[e[i].first]] &&
        !f[col[e[i].second]]) {
      int x = col[e[i].first], y = col[e[i].second];
      if (x > y) swap(x, y);
      if (!ma[{x, y}]) ma[{x, y}] = ++cnt;
      g[ma[{x, y}]].push_back(i);
    }
  }
  long long ans = 0;
  for (int i = 1; i <= cnt; i++) {
    int now = top;
    for (auto &j : g[i]) {
      int u = e[j].first, v = e[j].second;
      int fx = find(u), fy = find(v);
      int w = getd(u) ^ getd(v) ^ 1;
      if (fx != fy)
        merge(fx, fy, w);
      else if (w & 1) {
        ans--;
        break;
      }
    }
    while (top > now) clr();
  }
  long long tmp = 0;
  for (int i = 1; i <= k; i++)
    if (!f[i]) tmp++;
  ans += tmp * (tmp - 1) / 2;
  printf("%lld\n", ans);
}
