#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, w = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x * w;
}
inline void write(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
const long long maxn = 5e5 + 5;
const long long maxm = 26;
const long long mod = 998244353;
const long long inf = 0x3f3f3f3f3f3f3f;
const long long base = 1e5 + 5;
inline long long min(long long x, long long y) { return x < y ? x : y; }
inline long long max(long long x, long long y) { return x > y ? x : y; }
long long n, m, k, cnt, ans, tot, flag;
long long col[maxn], fa[maxn], g[maxn], siz[maxn], vis[maxn];
long long tp, sta[maxn];
inline long long find(long long x, long long &c) {
  c = 0;
  while (fa[x] != x) {
    c ^= g[x], x = fa[x];
  }
  return x;
}
inline bool merge(long long x, long long y) {
  long long res1 = 0, res2 = 0;
  x = find(x, res1);
  y = find(y, res2);
  long long w = res1 ^ res2 ^ 1;
  if (x == y) {
    if (w == 1) return 0;
    return 1;
  }
  if (siz[x] > siz[y]) swap(x, y);
  fa[x] = y, g[x] = w, siz[y] += siz[x];
  if (flag) sta[++tp] = x;
  return 1;
}
const long long kawaii_fkh = 1;
inline void del(long long x, long long y) {
  while (kawaii_fkh) {
    siz[x] -= y;
    if (fa[x] == x) return;
    x = fa[x];
  }
}
long long buc[maxn][2];
map<pair<long long, long long>, long long> mp;
vector<pair<long long, long long> > e[maxn];
signed main(void) {
  n = read(), m = read(), cnt = k = read();
  for (long long i = 1; i <= n; i++) col[i] = read(), fa[i] = i, siz[i] = 1;
  for (long long i = 1, u, v; i <= m; i++) {
    u = read(), v = read();
    if (col[u] != col[v]) {
      if (col[u] > col[v]) swap(u, v);
      pair<long long, long long> p = make_pair(col[u], col[v]);
      if (!mp.count(p)) {
        mp[p] = ++tot;
        buc[tot][0] = col[u], buc[tot][1] = col[v];
      }
      e[mp[p]].push_back(make_pair(u, v));
      continue;
    }
    if (!merge(u, v)) {
      if (!vis[col[u]]) cnt--;
      vis[col[u]] = 1;
    }
  }
  ans = cnt * (cnt - 1) / 2, flag = 1;
  for (long long i = 1; i <= tot; i++) {
    if (vis[buc[i][0]] || vis[buc[i][1]]) continue;
    long long fl = 1;
    for (pair<long long, long long> p : e[i]) {
      long long u = p.first, v = p.second;
      if (!merge(u, v)) {
        fl = 0;
        break;
      }
    }
    if (!fl) ans--;
    for (long long i = 1; i <= tp; i++) {
      if (fa[sta[i]] != sta[i]) del(fa[sta[i]], siz[sta[i]]);
      fa[sta[i]] = sta[i], g[sta[i]] = 0;
    }
    tp = 0;
  }
  printf("%lld\n", ans);
  return 0;
}
