#include <bits/stdc++.h>
using namespace std;
vector<string> vec_splitter(string s) {
  for (char& c : s) c = c == ',' ? ' ' : c;
  stringstream ss;
  ss << s;
  vector<string> res;
  for (string z; ss >> z; res.push_back(z))
    ;
  return res;
}
void debug_out(vector<string> args, int idx) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, Head H, Tail... T) {
  if (idx > 0) cerr << ", ";
  stringstream ss;
  ss << H;
  cerr << args[idx] << " = " << ss.str();
  debug_out(args, idx + 1, T...);
}
const long long N = 405, M = 3e5 + 5, D = 20000;
long long A[N], second[M], first[M], C[M], R[M], n, m, st = 1;
bool doit(long long idx, long long x) {
  long long city = second[idx], refuel = R[idx], currFuel = x;
  while (city != first[idx]) {
    long long fuelReq = (A[city + 1] - A[city]) * C[idx];
    if (fuelReq <= currFuel) {
      currFuel -= fuelReq;
      ++city;
      continue;
    }
    if (!refuel) return 0;
    refuel--;
    currFuel = x;
    if (fuelReq <= currFuel) {
      currFuel -= fuelReq;
      ++city;
      continue;
    }
    return 0;
  }
  return 1;
}
bool solve(long long x) {
  for (long long i = st; i <= m; ++i) {
    if (!doit(i, x)) {
      st = i;
      return 0;
    }
  }
  return 1;
}
int main() {
  scanf("%lld%lld", &n, &m);
  for (long long i = 1; i <= n; ++i) scanf("%lld", &A[i]);
  for (long long i = 1; i <= m; ++i)
    scanf("%lld%lld", &second[i], &first[i]), scanf("%lld%lld", &C[i], &R[i]);
  long long lo = 1, hi = 1e18, ans = 0;
  while (lo <= hi) {
    long long mid = lo + (hi - lo + 1) / D;
    if (solve(mid))
      ans = mid, hi = mid - 1;
    else
      lo = mid + 1;
  }
  printf("%lld\n", ans);
  return 0;
}
