#include <bits/stdc++.h>
using namespace std;
int n, m;
struct camion {
  int d, h, c, r;
};
camion t[250000];
int a[401];
bool sirve(int v, int idCamion) {
  int 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])) {
      return false;
    }
    if (litros < (a[i] - a[i - 1])) {
      if (cantRecargas) {
        litros = v;
        cantRecargas--;
      } else {
        return false;
      }
    }
    litros -= (a[i] - a[i - 1]);
  }
  return true;
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%d", &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);
  set<int> dif;
  for (int i = 1; i <= n; i++)
    for (int j = i; j <= n; j++) dif.insert(a[j] - a[i]);
  vector<int> diferencias;
  diferencias.reserve(dif.size());
  for (auto i : dif) diferencias.push_back(i);
  long long minV = 0;
  for (int i = 0; i < m; i++) {
    int ini = 0;
    int fin = diferencias.size() - 1;
    while (ini + 1 < fin) {
      int mid = (ini + fin) / 2;
      if (sirve(diferencias[mid], i)) {
        fin = mid;
      } else {
        ini = mid;
      }
    }
    if (sirve(diferencias[ini], i)) {
      minV = max(minV, ((long long)diferencias[ini]) * ((long long)t[i].c));
    } else {
      minV = max(minV, ((long long)diferencias[fin]) * ((long long)t[i].c));
    }
  }
  printf("%I64d\n", minV);
  return 0;
}
