#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
struct Node {
  int u, v, fa, rk;
  bool ds;
  Node(int _u = 0, int _v = 0, int _fa = 0, int _rk = 0, bool _ds = 0) {
    u = _u;
    v = _v;
    fa = _fa;
    rk = _rk;
    ds = _ds;
  }
} st[N];
int top;
struct USF {
  int fa[N], rk[N], c;
  bool ds[N];
  void init(int n) {
    for (int i = 1; i <= n; ++i) {
      fa[i] = i;
      rk[i] = 0;
      ds[i] = 0;
    }
  }
  int unite(int u, int v) {
    bool du = 0, dv = 0;
    while (u != fa[u]) du ^= ds[u], u = fa[u];
    while (v != fa[v]) dv ^= ds[v], v = fa[v];
    if (u == v) return du ^ dv;
    if (rk[u] < rk[v]) {
      swap(u, v);
      swap(du, dv);
    }
    st[++top] = Node(u, v, fa[v], rk[u], ds[v]);
    fa[v] = u;
    ds[v] = du ^ dv ^ 1;
    if (rk[u] == rk[v]) rk[u]++;
    return 2;
  }
  void undo(int t) {
    while (t--) {
      Node &o = st[top];
      --top;
      fa[o.v] = o.fa;
      ds[o.v] = o.ds;
      rk[o.u] = o.rk;
    }
  }
} usf;
int n, m, k, c[N];
struct Edge {
  int x, y;
  bool operator<(const Edge &r) const {
    if (c[x] != c[r.x])
      return c[x] < c[r.x];
    else
      return c[y] < c[r.y];
  }
  bool operator==(const Edge &r) const {
    return c[x] == c[r.x] && c[y] == c[r.y];
  }
} e[N];
bool nt[N];
int main() {
  scanf("%d %d %d", &n, &m, &k);
  usf.init(n);
  for (int i = 1; i <= n; ++i) scanf("%d", &c[i]);
  for (int i = 1; i <= m; ++i) {
    scanf("%d %d", &e[i].x, &e[i].y);
    if (c[e[i].x] == c[e[i].y]) {
      if (!nt[c[e[i].x]]) {
        if (usf.unite(e[i].x, e[i].y) == 0) {
          nt[c[e[i].x]] = true;
          --k;
        }
      }
      --i;
      --m;
    } else if (c[e[i].x] > c[e[i].y]) {
      swap(e[i].x, e[i].y);
    }
  }
  sort(e + 1, e + 1 + m);
  long long ans = 1ll * k * (k - 1) / 2;
  for (int i = 1, j = 1; i <= m; i = j) {
    int cnt = 0, op, flg = nt[c[e[i].x]] | nt[c[e[i].y]];
    while (j <= m && e[j] == e[i]) {
      if (!flg) {
        op = usf.unite(e[j].x, e[j].y);
        if (op == 0) {
          flg = 1;
          --ans;
        } else if (op == 2)
          ++cnt;
      }
      ++j;
    }
    usf.undo(cnt);
  }
  printf("%lld\n", ans);
}
