#include <bits/stdc++.h>
using namespace std;
int fa[510000], val[510000], siz[510000], zanval;
int findfa(int x) {
  zanval = 0;
  int y = x;
  while (fa[y] != y) zanval ^= val[y], y = fa[y];
  return y;
}
inline bool mer(int x, int y, int type) {
  int tx = findfa(x);
  type ^= zanval;
  int ty = findfa(y);
  type ^= zanval;
  if (tx == ty) {
    if (type == 1) return 0;
  } else {
    if (siz[tx] > siz[ty])
      fa[ty] = tx, siz[tx] += siz[ty], val[ty] = type;
    else
      fa[tx] = ty, siz[ty] += siz[tx], val[tx] = type;
  }
  return 1;
}
struct node {
  int id;
  int x, y;
  node(int idx = 0, int xx = 0, int yx = 0) {
    id = idx;
    x = xx;
    y = yx;
  }
};
vector<node> fuck[510000];
node sta[510000];
int top;
int n, m, k, be[510000];
bool shit[510000];
int shitcnt;
bool tis[510000];
int pre[510000], pre_top;
inline void check(int x) {
  x = findfa(x);
  if (!tis[x]) {
    tis[x] = 1;
    pre[++pre_top] = x;
  }
}
inline bool solve(int l, int r) {
  pre_top = 0;
  for (int i = l; i <= r; i++) {
    int x = sta[i].x, y = sta[i].y;
    check(x);
    check(y);
    if (!mer(x, y, 1)) return 1;
  }
  return 0;
}
inline void put_hui() {
  for (int i = 1; i <= pre_top; i++)
    fa[pre[i]] = pre[i], val[pre[i]] = 0, tis[pre[i]] = 0;
}
inline bool cmp(node x, node y) { return x.id < y.id; }
int main() {
  scanf("%d%d%d", &n, &m, &k);
  shitcnt = k;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &be[i]);
    fa[i] = i;
    siz[i] = 1;
  }
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (be[x] == be[y]) {
      if (!shit[be[x]]) {
        if (!mer(x, y, 1)) {
          shit[be[x]] = 1;
          shitcnt--;
        }
      }
    } else {
      fuck[be[x]].push_back(node(be[y], x, y));
      fuck[be[y]].push_back(node(be[x], y, x));
    }
  }
  long long ans = (long long)shitcnt * (shitcnt - 1) / 2;
  long long fei = 0;
  for (int i = 1; i <= k; i++) {
    if (shit[i]) continue;
    top = fuck[i].size();
    for (int j = 0; j < top; j++) sta[j + 1] = fuck[i][j];
    sort(sta + 1, sta + top + 1, cmp);
    int tmp = sta[1].id, tmppre = 1;
    for (int j = 1; j <= top; j++) {
      if (sta[j].id != tmp) {
        if (!shit[tmp]) {
          fei += solve(tmppre, j - 1);
          put_hui();
        }
        tmppre = j;
        tmp = sta[j].id;
      }
    }
    if (top && !shit[sta[top].id]) {
      fei += solve(tmppre, top);
      put_hui();
    }
  }
  printf("%lld\n", ans - fei / 2);
  return 0;
}
