#include <bits/stdc++.h>
using namespace std;
int n, m;
struct camion {
  int d, h, c, r;
};
camion t[250000];
long long a[401];
bool sirve(long long v, int idCamion) {
  long long litros = v;
  int cantRecargas = t[idCamion].r;
  for (int i = t[idCamion].d + 1; i <= t[idCamion].h; i++) {
    if (v < (a[i] - a[i - 1]) * t[idCamion].c) {
      return false;
    }
    if (litros < (a[i] - a[i - 1]) * t[idCamion].c) {
      if (cantRecargas) {
        litros = v;
        cantRecargas--;
      } else {
        return false;
      }
    }
    litros -= (a[i] - a[i - 1]) * t[idCamion].c;
  }
  return true;
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%I64d", &a[i + 1]);
  for (int i = 0; i < m; i++)
    scanf("%d %d %d %d", &t[i].d, &t[i].h, &t[i].c, &t[i].r);
  unsigned seed = time(0);
  shuffle(t, t + m, default_random_engine(seed));
  long long minV = 0;
  int v = 0;
  long long ini, fin, mid;
  for (int i = 0; i < m; i++) {
    if (!sirve(minV, i)) {
      ini = minV;
      fin = (1000000000000000000);
      while (ini + 1 < fin) {
        mid = (ini + fin) / 2;
        if (sirve(mid, i))
          fin = mid;
        else
          ini = mid;
      }
      if (sirve(ini, i))
        minV = ini;
      else
        minV = fin;
    }
  }
  printf("%I64d\n", minV);
  return 0;
}
