#include <bits/stdc++.h>
using namespace std;
const long long MAX_V = 1e18 + 1;
const int MAXTRUCK = 250000;
const int MAXN = 400;
struct TRUCK {
  int s, f;
  int r;
  long long c;
  friend istream& operator>>(istream& in, TRUCK& yo) {
    in >> yo.s >> yo.f;
    yo.s--;
    yo.f--;
    in >> yo.c;
    in >> yo.r;
    return in;
  }
};
int n, m;
long long a[MAXN + 2];
TRUCK truck[MAXTRUCK + 2];
bool alcanza(int idx, long long V) {
  int recargas = truck[idx].r;
  long long costo = truck[idx].c;
  long long cap = V;
  for (int i = truck[idx].s; i < truck[idx].f; i++) {
    long long dist = (a[i + 1] - a[i]) * costo;
    if (dist <= cap) {
      cap -= dist;
    } else {
      if (recargas == 0) {
        return false;
      }
      cap = V;
      recargas--;
      i--;
    }
  }
  return true;
}
long long busca_min(int idx, long long izq = 0) {
  long long der = MAX_V;
  while (izq < der) {
    long long medio = (der - izq) / 2;
    medio += izq;
    if (alcanza(idx, medio)) {
      der = medio;
    } else {
      izq = medio + 1;
    }
  }
  return izq;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < m; ++i) cin >> truck[i];
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  shuffle(truck, truck + m, rng);
  long long V = 0;
  for (int i = 0; i < m; ++i) {
    if (alcanza(i, V)) continue;
    V = busca_min(i, V);
  }
  cout << V << '\n';
  return 0;
}
